package com.forbet.demo.task;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONException;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.tokenizers.Tokenization;
import com.alibaba.dashscope.tokenizers.TokenizationResult;
import com.alibaba.dashscope.utils.JsonUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.forbet.demo.common.EnumCommon;
import com.forbet.demo.mapper.*;
import com.forbet.demo.po.*;
import com.forbet.demo.service.*;
import com.forbet.demo.util.AlibabaUtils;
import com.forbet.demo.vo.AsianBankerInfoVO;
import com.forbet.demo.vo.BigSmallInfoVO;
import com.forbet.demo.vo.EuropeBankerInfoVO;
import com.forbet.demo.vo.HotTransactionVo;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.internal.StringUtil;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @author:hading
 * @create: 2023-11-23 23:43:44
 * @Description: 自动拉取数据定时任务
 */


@EnableScheduling//开启定时任务
@Component
public class AutoUpdateInfoTask {

    @Autowired
    private AsianBankerInfoMapper asianBankerInfoMapper;

    @Autowired
    private AsianBankerInfoService asianBankerInfoService;

    @Autowired
    private EuropeBankerInfoMapper europeBankerInfoMapper;

    @Autowired
    private EuropeBankerInfoService europeBankerInfoService;

    @Autowired
    private PlayInfoMapper playInfoMapper;

    @Autowired
    private PlayInfoService playInfoService;

    @Autowired
    private PredictAccuracyMapper predictAccuracyMapper;

    @Autowired
    private BigSmallInfoMapper bigSmallInfoMapper;

    @Autowired
    private PredictAccuracyService predictAccuracyService;

    @Autowired
    private BigSmallInfoService bigSmallInfoService;


    //    log
    protected Log log = LogFactory.getLog(this.getClass());


    /**
     * 自动拉取数据和更新数据(国内，赔率时间有误差)
     */
//    @Scheduled(cron = "0 30 17 * * ?") //每20分钟自动执行一次
    @Scheduled(cron = "0 0/30 * * * ?") //每20分钟自动执行一次
    @Transactional
    public void autoGetAndUpdateInfo() throws Exception {
        List<PlayInfoPO> updatePlayList = null;
        List<AsianBankerInfoPO> insertAsianList = null;
        List<EuropeBankerInfoPO> insertEuropeList = null;
        List<BigSmallInfo> insertBigSmallInfoList = null;
        Document document = null;
        try {
            Connection conn = Jsoup.connect("https://live.500.com/2h1.php").timeout(10000);
            conn.maxBodySize(0);
            conn.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
            conn.header("Accept-Encoding", "gzip, deflate, sdch");
            conn.header("Accept-Language", "zh-CN,zh;q=0.8");
            conn.header("User-Agent", "Mozilla");
//      获取真实的数据体
            document = conn.get();
        } catch (IOException e) {
            log.error("https://live.500.com/2h1.php无法访问,暂时跳过");
            log.error(e.getMessage());
            return;
        }
        Element element = document.getElementById("table_match");
            Elements trList = element.getElementsByTag("tr");


//        List<PlayInfoPO> insertPlayList = new ArrayList<>();
            updatePlayList = new ArrayList<>();
            insertAsianList = new ArrayList<>();
            insertEuropeList = new ArrayList<>();
            insertBigSmallInfoList = new ArrayList<>();
            int yearInt = DateUtil.thisYear();

//        从第2个开始，第1个数据没用
            big:
            for (int i = 1; i < trList.size(); i++) {
                Element idEl = trList.get(i);
                String idStr = idEl.toString();
    //            没有id说明已经到了加时赛的数据，先不爬取,直接退出
                if (!idStr.contains("id")) {
                    continue;
                }
                Elements tdList = trList.get(i).getElementsByTag("td");
                if (StringUtils.isBlank(trList.get(i).id())) {
                    continue;
                }

    //            先查询是否添加过该条比赛信息
                LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getEventName, tdList.get(1).getElementsByTag("a").text());
                playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getHomeName, tdList.get(5).getElementsByTag("a").text());
                playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getVisitName, tdList.get(7).getElementsByTag("a").text());
    //            本年

                String time = tdList.get(3).text();
                DateTime timeParse = DateUtil.parse(yearInt + " " + time, "yyyy MM-dd HH:mm");
                playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getPlayingTime, timeParse);//如果比赛时间被后期推迟修改，则可能会多出来一条数据，无所谓。
    //            playInfoPOLambdaQueryWrapper.select(PlayInfoPO::getId);
                List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
                PlayInfoPO playInfoPO = null;
                if (playInfoPOS == null || playInfoPOS.size() == 0) {
                    //                赛事名称
                    playInfoPO = new PlayInfoPO();
                    playInfoPO.setEventName(tdList.get(1).getElementsByTag("a").text());
    //                比赛时间
                    playInfoPO.setPlayingTime(timeParse);

                    //                主队名称
                    playInfoPO.setHomeName(tdList.get(5).getElementsByTag("a").text());

    //                当前主队比分
                    Elements pk = tdList.get(6).getElementsByTag("div");
                    String homeScore = pk.get(0).getElementsByTag("a").get(0).text();
                    String visitScore = pk.get(0).getElementsByTag("a").get(2).text();
                    if (StringUtils.isNotBlank(homeScore)) {
                        playInfoPO.setHomeScore(Integer.parseInt(homeScore));
                    }
    //                当前客队比分
                    if (StringUtils.isNotBlank(visitScore)) {
                        playInfoPO.setVisitScore(Integer.parseInt(visitScore));
                    }
    //                客队名称
                    playInfoPO.setVisitName(tdList.get(7).getElementsByTag("a").text());
                    playInfoPO.setPredictResultAsian("");//给个空值
                    playInfoService.save(playInfoPO);
    //                insertPlayList.add(playInfoPO);
                } else {
                    playInfoPO = playInfoPOS.get(0);
                    Elements pk = tdList.get(6).getElementsByTag("div");
                    String homeScore = pk.get(0).getElementsByTag("a").get(0).text();
                    String visitScore = pk.get(0).getElementsByTag("a").get(2).text();
                    if (StringUtils.isNotBlank(homeScore)) {
                        playInfoPO.setHomeScore(Integer.parseInt(homeScore));
                    }
    //                当前客队比分
                    if (StringUtils.isNotBlank(visitScore)) {
                        playInfoPO.setVisitScore(Integer.parseInt(visitScore));
                    }
                    if(playInfoPO.getPredictResultAsian() == null){
                        playInfoPO.setPredictResultAsian("");//给个空值
                    }
                    updatePlayList.add(playInfoPO);
    //                有的话就赋值，下面小循环要用这个id做外键。
                }

    //            找到该条数据id，然后进入亚赔页面
                String id = idStr.substring(idStr.indexOf("id=\"") + 5, idStr.indexOf("status=") - 2);

    //                    进入亚赔 ↓↓↓↓↓↓↓↓↓↓↓↓
    //              当前比赛进行到什么时间
    //                如果是‘未’ 开场，再去计算赔率，胜率
                if ("未".equals(tdList.get(4).text())) {
                    Document asianOdds = null;
                    try {
                        Connection conn2 = Jsoup.connect("https://odds.500.com/fenxi/yazhi-" + id + ".shtml").timeout(30000);
                        conn2.maxBodySize(0);
                        conn2.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn2.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn2.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn2.header("User-Agent", "Mozilla");
                        asianOdds = conn2.get();
                    } catch (IOException e) {
                        log.error("https://odds.500.com/fenxi/yazhi-" + id + ".shtml" + "无法访问,暂时跳过");
                        log.error(e.getMessage());
                        continue;//这场网没连上就直接爬下一场即可
                    }
                    Element datatb = asianOdds.getElementById("datatb");
                    Elements asianTrList1 = datatb.getElementsByClass("tr1");
                    Elements asianTrList2 = datatb.getElementsByClass("tr2");
    //                    二合一
                    asianTrList1.addAll(asianTrList2);
    //                二合一后,拿所有公司，不止是主流
                    Elements mostEleList = new Elements();
                    for (Element element1 : asianTrList1
                    ) {
                        Elements src1 = element1.getElementsByAttributeValue("src", "/images/oz_zhu.gif");
                        if (src1.size() != 0) {
                            mostEleList.add(element1);
                        }
                    }
    //                    对每条庄家数据进行循环
                    for (Element tr : mostEleList
                    ) {
    //                        会有2个class叫: pl_table_data的属性,一个初盘一个即盘
                        Elements plTableData = tr.getElementsByClass("pl_table_data");
    //                        即时盘口的td标签数据
                        Elements td = plTableData.get(0).getElementsByTag("td");
    //                        初始盘口的td标签数据
                        Elements td2 = plTableData.get(1).getElementsByTag("td");
    //                        即时主队盘口赔率
                        String homeDrib = td.get(0).text();
    //                        即时主队盘口让球情况
                        String homeDribName = td.get(1).text();
    //                        即时客队盘口赔率
                        String visitDrib = td.get(2).text();

    //                        初始主队盘口赔率
                        String homeDrib2 = td2.get(0).text();
    //                        初始主队盘口让球情况
                        String homeDrib2Name = td2.get(1).text();
    //                        初始客队盘口赔率
                        String visitDrib2 = td2.get(2).text();

                        Elements tbPlgs = tr.getElementsByClass("tb_plgs");
                        //                        赔率公司名称
                        Elements quancheng = tbPlgs.get(0).getElementsByClass("quancheng");

                        //                            查看有无初盘数据，无则添加
                        LambdaQueryWrapper<AsianBankerInfoPO> bankerInfoPOLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getBankerName, quancheng.text());
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getStartNowHandicapFlag, "0");//初盘
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getHomeHandicap, new BigDecimal(homeDrib2));
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getVisitHandicap, new BigDecimal(visitDrib2));
                        DateTime timeParse3 = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(12).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getCreateTime, timeParse3);
                        List<AsianBankerInfoPO> asianBankerInfoPOS2 = asianBankerInfoMapper.selectList(bankerInfoPOLambdaQueryWrapper2);
    //                            如果没添加过再添加
                        if (asianBankerInfoPOS2 == null || asianBankerInfoPOS2.size() == 0) {
    //                            添加初始数据
                            AsianBankerInfoPO asianBankerInfoPO = new AsianBankerInfoPO();
                            asianBankerInfoPO.setBankerName(quancheng.text());
                            asianBankerInfoPO.setPlayInfoId(playInfoPO.getId());
                            asianBankerInfoPO.setHomeHandicap(new BigDecimal(homeDrib2));
                            asianBankerInfoPO.setVisitHandicap(new BigDecimal(visitDrib2));
                            asianBankerInfoPO.setStartNowHandicapFlag("0");// 0: 初盘
                            asianBankerInfoPO.setCreateTime(timeParse3);
                            asianBankerInfoPO.setHandicapName(homeDrib2Name);
                            insertAsianList.add(asianBankerInfoPO);
                        } else {
                            //                        看同一时间同一庄家同一场比赛的即盘数据是否存在，只有在相同时间和相同赔率的情况下不需要新增数据。说明没有更新数据。
                            LambdaQueryWrapper<AsianBankerInfoPO> bankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getBankerName, quancheng.text());
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getStartNowHandicapFlag, "1");//即盘
                            //                            箭头符号删除掉
                            homeDrib = homeDrib.replaceAll("↑", "").replaceAll("↓", "");
                            visitDrib = visitDrib.replaceAll("↑", "").replaceAll("↓", "");
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getHomeHandicap, new BigDecimal(homeDrib));
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getVisitHandicap, new BigDecimal(visitDrib));
                            DateTime timeParse2 = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(7).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getCreateTime, timeParse2);

                            List<AsianBankerInfoPO> asianBankerInfoPOS = asianBankerInfoMapper.selectList(bankerInfoPOLambdaQueryWrapper);
                            if (asianBankerInfoPOS == null || asianBankerInfoPOS.size() == 0) {
    //                            添加即时的盘口数据
                                AsianBankerInfoPO asianBankerInfoPO = new AsianBankerInfoPO();
                                asianBankerInfoPO.setBankerName(quancheng.text());
                                asianBankerInfoPO.setPlayInfoId(playInfoPO.getId());
    //                            箭头符号删除掉
                                asianBankerInfoPO.setHomeHandicap(new BigDecimal(homeDrib));
                                asianBankerInfoPO.setVisitHandicap(new BigDecimal(visitDrib));
                                asianBankerInfoPO.setStartNowHandicapFlag("1");// 1: 即盘
                                asianBankerInfoPO.setCreateTime(timeParse2);
                                asianBankerInfoPO.setHandicapName(homeDribName);
                                insertAsianList.add(asianBankerInfoPO);
    //                        asianBankerInfoMapper.insert(asianBankerInfoPO);
                            }
                        }
                    }

    //              进入大小球↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
                    Document europeOdds2 = null;
                    try {
                        Connection conn4 = Jsoup.connect("https://odds.500.com/fenxi/daxiao-" + id + ".shtml").timeout(30000);
                        conn4.maxBodySize(0);
                        conn4.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn4.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn4.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn4.header("User-Agent", "Mozilla");
                        europeOdds2 = conn4.get();
                    } catch (IOException e) {
                        log.error("https://odds.500.com/fenxi/daxiao-" + id + ".shtml" + "无法访问,暂时跳过");
                        log.error(e.getMessage());
                        continue;//这场网没连上就直接爬下一场即可
                    }
                    Element datatb3 = europeOdds2.getElementById("datatb");
                    Elements europeTrList3 = datatb3.getElementsByClass("tr1");
                    Elements europeTrList4 = datatb3.getElementsByClass("tr2");
                    //                    二合一
                    europeTrList3.addAll(europeTrList4);
                    //                二合一后把所有主流公司筛选出来
                    Elements mostEleList3 = new Elements();
                    for (Element element1 : europeTrList3
                    ) {
                        Elements src1 = element1.getElementsByAttributeValue("src", "/images/oz_zhu.gif");
                        if (src1.size() != 0) {
                            mostEleList3.add(element1);
                        }
                    }
    //                    对每条庄家数据进行循环
                    for (Element tr : mostEleList3
                    ) {
                        Elements plTableData = tr.getElementsByClass("pl_table_data");
                        Elements td = plTableData.get(0).getElementsByTag("td");

    //                        即盘大小球赔率
                        Element newBig = td.get(0);
                        Element newHandcapName = td.get(1);//即盘的大小球盘口值
                        Element newSmall = td.get(2);

                        Elements td2 = plTableData.get(1).getElementsByTag("td");
    //                        初盘大小球赔率
                        Element oldBig = td2.get(0);
                        Element oldHandcapName = td2.get(1);//初盘的大小球盘口值
                        Element oldSmall = td2.get(2);

                        Elements tbPlgs = tr.getElementsByClass("tb_plgs");
    //                        赔率公司名称
                        Elements quancheng = tbPlgs.get(0).getElementsByClass("quancheng");

    //                    初盘盘口的时间
                        DateTime dateTime = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(12).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");
                        LambdaQueryWrapper<BigSmallInfo> bigSmallInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getPlayInfoId, playInfoPO.getId());
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getBankerName, quancheng.text());
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getBigHandicap, new BigDecimal(oldBig.text().replaceAll("↑", "").replaceAll("↓", "")));
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getSmallHandicap, new BigDecimal(oldSmall.text().replaceAll("↑", "").replaceAll("↓", "")));
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getHandicapName, oldHandcapName.text().replaceAll("↑", "").replaceAll("↓", ""));
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getStartNowHandicapFlag, "0");
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getCreateTime, dateTime);
                        List<BigSmallInfo> bigSmallInfoList = bigSmallInfoMapper.selectList(bigSmallInfoLambdaQueryWrapper);

    //                        初盘没数据的话则添加一条！
                        if (bigSmallInfoList == null || bigSmallInfoList.size() == 0) {
                            BigSmallInfo bigSmallInfo = new BigSmallInfo();
                            bigSmallInfo.setBankerName(quancheng.text());
                            bigSmallInfo.setBigHandicap(new BigDecimal(oldBig.text().replaceAll("↑", "").replaceAll("↓", "")));
                            bigSmallInfo.setSmallHandicap(new BigDecimal(oldSmall.text().replaceAll("↑", "").replaceAll("↓", "")));
                            bigSmallInfo.setHandicapName(oldHandcapName.text().replaceAll("↑", "").replaceAll("↓", ""));
    //                            添加即时数据
                            bigSmallInfo.setPlayInfoId(playInfoPO.getId());
                            bigSmallInfo.setStartNowHandicapFlag("0");// 0: 初盘
                            bigSmallInfo.setCreateTime(dateTime);
                            insertBigSmallInfoList.add(bigSmallInfo);
                        } else {
    //                            初盘有数据，看下即盘
                            DateTime dateTime2 = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(7).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");

                            LambdaQueryWrapper<BigSmallInfo> bigSmallInfoLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getPlayInfoId, playInfoPO.getId());
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getBankerName, quancheng.text());
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getBigHandicap, new BigDecimal(newBig.text().replaceAll("↑", "").replaceAll("↓", "")));
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getSmallHandicap, new BigDecimal(newSmall.text().replaceAll("↑", "").replaceAll("↓", "")));
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getStartNowHandicapFlag, "1");
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getHandicapName, newHandcapName.text().replaceAll("↑", "").replaceAll("↓", ""));
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getCreateTime, dateTime2);
                            List<BigSmallInfo> bigSmallInfoList2 = bigSmallInfoMapper.selectList(bigSmallInfoLambdaQueryWrapper2);
    //                            没有即盘数据则添加，有可能是发生了变化，继续添加即可。
                            if (bigSmallInfoList2 == null || bigSmallInfoList2.size() == 0) {
                                BigSmallInfo bigSmallInfo = new BigSmallInfo();
                                bigSmallInfo.setBankerName(quancheng.text());
                                bigSmallInfo.setBigHandicap(new BigDecimal(newBig.text().replaceAll("↑", "").replaceAll("↓", "")));
                                bigSmallInfo.setSmallHandicap(new BigDecimal(newSmall.text().replaceAll("↑", "").replaceAll("↓", "")));
                                bigSmallInfo.setHandicapName(newHandcapName.text().replaceAll("↑", "").replaceAll("↓", ""));
    //                            添加即时数据
                                bigSmallInfo.setPlayInfoId(playInfoPO.getId());
                                bigSmallInfo.setStartNowHandicapFlag("1");// 1: 即盘
                                bigSmallInfo.setCreateTime(dateTime2);
                                insertBigSmallInfoList.add(bigSmallInfo);
                            }
                        }
                    }

    //                    进入欧赔↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
                    Document europeOdds = null;
                    try {
                        Connection conn3 = Jsoup.connect("https://odds.500.com/fenxi/ouzhi-" + id + ".shtml").timeout(30000);
                        conn3.maxBodySize(0);
                        conn3.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn3.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn3.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn3.header("User-Agent", "Mozilla");
                        europeOdds = conn3.get();
                    } catch (IOException e) {
                        log.error("https://odds.500.com/fenxi/ouzhi-" + id + ".shtml" + "无法访问,暂时跳过");
                        log.error(e.getMessage());
                        continue;//这场网没连上就直接爬下一场即可
                    }
                    Element datatb2 = europeOdds.getElementById("datatb");
                    Elements europeTrList1 = datatb2.getElementsByClass("tr1");
                    Elements europeTrList2 = datatb2.getElementsByClass("tr2");
                    //                    二合一
                    europeTrList1.addAll(europeTrList2);
                    //                二合一后把所有主流公司筛选出来
                    Elements mostEleList2 = new Elements();
                    for (Element element1 : europeTrList1
                    ) {
                        Elements src1 = element1.getElementsByAttributeValue("src", "/images/oz_zhu.gif");
                        if (src1.size() != 0) {
                            mostEleList2.add(element1);
                        }
                    }
    //                    对每条庄家数据进行循环
                    for (Element tr : mostEleList2
                    ) {
                        Elements plTableData = tr.getElementsByClass("pl_table_data");
                        Elements td = plTableData.get(0).getElementsByTag("td");
    //                        初盘主队赔率
                        Element winTd1 = td.get(0);
                        Element drawTd1 = td.get(1);
                        Element loseTd1 = td.get(2);
    //                        即盘主队赔率
                        Element winTd2 = td.get(3);
                        Element drawTd2 = td.get(4);
                        Element loseTd2 = td.get(5);

                        Elements tbPlgs = tr.getElementsByClass("tb_plgs");
    //                        赔率公司名称
                        Elements quancheng = tbPlgs.get(0).getElementsByClass("quancheng");

                        Date nowDate = new Date();
                        LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getBankerName, quancheng.text());
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeWinHandicap, new BigDecimal(winTd1.text()));
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeDrawHandicap, new BigDecimal(drawTd1.text()));
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeLoseHandicap, new BigDecimal(loseTd1.text()));
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getStartNowHandicapFlag, "0");
    //                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getCreateTime, nowDate);
                        List<EuropeBankerInfoPO> europeBankerInfoPOList = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper);
    //                        初盘没数据的话则添加一条！
                        if (europeBankerInfoPOList == null || europeBankerInfoPOList.size() == 0) {
                            EuropeBankerInfoPO europeBankerInfoPO = new EuropeBankerInfoPO();
                            europeBankerInfoPO.setBankerName(quancheng.text());
                            europeBankerInfoPO.setHomeWinHandicap(new BigDecimal(winTd1.text()));
                            europeBankerInfoPO.setHomeDrawHandicap(new BigDecimal(drawTd1.text()));
                            europeBankerInfoPO.setHomeLoseHandicap(new BigDecimal(loseTd1.text()));
    //                            添加即时数据
                            europeBankerInfoPO.setPlayInfoId(playInfoPO.getId());
                            europeBankerInfoPO.setStartNowHandicapFlag("0");// 0: 初盘
                            europeBankerInfoPO.setCreateTime(nowDate);
                            insertEuropeList.add(europeBankerInfoPO);
    //                        europeBankerInfoMapper.insert(europeBankerInfoPO);
                        } else {
    //                            初盘有数据，看下即盘
                            LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getBankerName, quancheng.text());
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeWinHandicap, new BigDecimal(winTd2.text()));
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeDrawHandicap, new BigDecimal(drawTd2.text()));
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeLoseHandicap, new BigDecimal(loseTd2.text()));
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getStartNowHandicapFlag, "1");
                            List<EuropeBankerInfoPO> europeBankerInfoPOList2 = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper2);
    //                            没有即盘数据则添加，有可能是发生了变化，继续添加即可。
                            if (europeBankerInfoPOList2 == null || europeBankerInfoPOList2.size() == 0) {
                                EuropeBankerInfoPO europeBankerInfoPO = new EuropeBankerInfoPO();
                                europeBankerInfoPO.setBankerName(quancheng.text());
                                europeBankerInfoPO.setHomeWinHandicap(new BigDecimal(winTd2.text()));
                                europeBankerInfoPO.setHomeDrawHandicap(new BigDecimal(drawTd2.text()));
                                europeBankerInfoPO.setHomeLoseHandicap(new BigDecimal(loseTd2.text()));
    //                            添加即时数据
                                europeBankerInfoPO.setPlayInfoId(playInfoPO.getId());
                                europeBankerInfoPO.setStartNowHandicapFlag("1");// 1: 即盘
                                europeBankerInfoPO.setCreateTime(nowDate);
                                insertEuropeList.add(europeBankerInfoPO);
                            }
                        }
                    }

                    Document shujuOdds = null;
                    try {
                        Connection conn5 = Jsoup.connect("https://odds.500.com/fenxi/shuju-" + id + ".shtml").timeout(30000);
                        conn5.maxBodySize(0);
                        conn5.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn5.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn5.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn5.header("User-Agent", "Mozilla");
                        shujuOdds = conn5.get();
                    } catch (IOException e) {
                        log.error("https://odds.500.com/fenxi/shuju-" + id + ".shtml" + "无法访问,暂时跳过");
                        log.error(e.getMessage());
                        continue;//这场网没连上就直接爬下一场即可
                    }
                    Elements elementsByClass = shujuOdds.getElementsByClass("pub_table");

                    JSONObject jsonObject = new JSONObject();

                    int flag = 0;
    //                如果是杯赛，则设置flag = 1这样去获取数据
                    if ("赛前联赛积分排名".equals(shujuOdds.getElementsByClass("M_title").get(1).text())) {
                        flag = 1;
                        jsonObject.set("赛事类型", "杯赛");
                    }

    //              主队赛前联赛积分排名

                    if (elementsByClass.size() > flag && elementsByClass.get(flag) != null) {
                        Elements tdElements = elementsByClass.get(flag).getElementsByTag("td");

                        // 检查每个索引是否有效，并提取数据
                        if (tdElements.size() > 1 && StringUtils.isNotBlank(tdElements.get(1).text())) {
                            String text1 = tdElements.get(1).text();
                            jsonObject.set("主队本赛季该赛事总计比赛次数", text1);
                        }
                        if (tdElements.size() > 2 && StringUtils.isNotBlank(tdElements.get(2).text())) {
                            String text2 = tdElements.get(2).text();
                            jsonObject.set("主队本赛季该赛事获胜比赛次数", text2);
                        }
                        if (tdElements.size() > 3 && StringUtils.isNotBlank(tdElements.get(3).text())) {
                            String text3 = tdElements.get(3).text();
                            jsonObject.set("主队本赛季该赛事平局比赛次数", text3);
                        }
                        if (tdElements.size() > 4 && StringUtils.isNotBlank(tdElements.get(4).text())) {
                            String text4 = tdElements.get(4).text();
                            jsonObject.set("主队本赛季该赛事输球比赛次数", text4);
                        }
                        if (tdElements.size() > 5 && StringUtils.isNotBlank(tdElements.get(5).text())) {
                            String text5 = tdElements.get(5).text();
                            jsonObject.set("主队本赛季该赛事进球数量", text5);
                        }
                        if (tdElements.size() > 6 && StringUtils.isNotBlank(tdElements.get(6).text())) {
                            String text6 = tdElements.get(6).text();
                            jsonObject.set("主队本赛季该赛事丢球数量", text6);
                        }
                        if (tdElements.size() > 7 && StringUtils.isNotBlank(tdElements.get(7).text())) {
                            String text7 = tdElements.get(7).text();
                            jsonObject.set("主队本赛季该赛事净胜球数量", text7);
                        }
                        if (tdElements.size() > 8 && StringUtils.isNotBlank(tdElements.get(8).text())) {
                            String text8 = tdElements.get(8).text();
                            jsonObject.set("主队本赛季该赛事目前积分", text8);
                        }
                        if (tdElements.size() > 9 && StringUtils.isNotBlank(tdElements.get(9).text())) {
                            String text9 = tdElements.get(9).text();
                            jsonObject.set("主队本赛季该赛事目前排名", text9);
                        }
                        if (tdElements.size() > 10 && StringUtils.isNotBlank(tdElements.get(10).text())) {
                            String text10 = tdElements.get(10).text();
                            jsonObject.set("主队本赛季该赛事胜率", text10);
                        }

                        // 主场数据
                        if (tdElements.size() > 12 && StringUtils.isNotBlank(tdElements.get(12).text())) {
                            String text12 = tdElements.get(12).text();
                            jsonObject.set("主队本赛季该赛事主场比赛次数", text12);
                        }
                        if (tdElements.size() > 13 && StringUtils.isNotBlank(tdElements.get(13).text())) {
                            String text13 = tdElements.get(13).text();
                            jsonObject.set("主队本赛季该赛事主场获胜次数", text13);
                        }
                        if (tdElements.size() > 14 && StringUtils.isNotBlank(tdElements.get(14).text())) {
                            String text14 = tdElements.get(14).text();
                            jsonObject.set("主队本赛季该赛事主场平局次数", text14);
                        }
                        if (tdElements.size() > 15 && StringUtils.isNotBlank(tdElements.get(15).text())) {
                            String text15 = tdElements.get(15).text();
                            jsonObject.set("主队本赛季该赛事主场输球次数", text15);
                        }
                        if (tdElements.size() > 16 && StringUtils.isNotBlank(tdElements.get(16).text())) {
                            String text16 = tdElements.get(16).text();
                            jsonObject.set("主队本赛季该赛事主场进球数量", text16);
                        }
                        if (tdElements.size() > 17 && StringUtils.isNotBlank(tdElements.get(17).text())) {
                            String text17 = tdElements.get(17).text();
                            jsonObject.set("主队本赛季该赛事主场丢球数量", text17);
                        }
                        if (tdElements.size() > 18 && StringUtils.isNotBlank(tdElements.get(18).text())) {
                            String text18 = tdElements.get(18).text();
                            jsonObject.set("主队本赛季该赛事主场净胜球数量", text18);
                        }
                        if (tdElements.size() > 21 && StringUtils.isNotBlank(tdElements.get(21).text())) {
                            String text21 = tdElements.get(21).text();
                            jsonObject.set("主队本赛季该赛事主场胜率", text21);
                        }

                        // 客场数据
                        if (tdElements.size() > 23 && StringUtils.isNotBlank(tdElements.get(23).text())) {
                            String text23 = tdElements.get(23).text();
                            jsonObject.set("主队本赛季该赛事客场比赛次数", text23);
                        }
                        if (tdElements.size() > 24 && StringUtils.isNotBlank(tdElements.get(24).text())) {
                            String text24 = tdElements.get(24).text();
                            jsonObject.set("主队本赛季该赛事客场获胜次数", text24);
                        }
                        if (tdElements.size() > 25 && StringUtils.isNotBlank(tdElements.get(25).text())) {
                            String text25 = tdElements.get(25).text();
                            jsonObject.set("主队本赛季该赛事客场平局次数", text25);
                        }
                        if (tdElements.size() > 26 && StringUtils.isNotBlank(tdElements.get(26).text())) {
                            String text26 = tdElements.get(26).text();
                            jsonObject.set("主队本赛季该赛事客场输球次数", text26);
                        }
                        if (tdElements.size() > 27 && StringUtils.isNotBlank(tdElements.get(27).text())) {
                            String text27 = tdElements.get(27).text();
                            jsonObject.set("主队本赛季该赛事客场进球数量", text27);
                        }
                        if (tdElements.size() > 28 && StringUtils.isNotBlank(tdElements.get(28).text())) {
                            String text28 = tdElements.get(28).text();
                            jsonObject.set("主队本赛季该赛事客场丢球数量", text28);
                        }
                        if (tdElements.size() > 29 && StringUtils.isNotBlank(tdElements.get(29).text())) {
                            String text29 = tdElements.get(29).text();
                            jsonObject.set("主队本赛季该赛事客场净胜球数量", text29);
                        }
                        if (tdElements.size() > 32 && StringUtils.isNotBlank(tdElements.get(32).text())) {
                            String text32 = tdElements.get(32).text();
                            jsonObject.set("主队本赛季该赛事客场胜率", text32);
                        }
                    }

                    if (elementsByClass.size() > (flag + 1) && elementsByClass.get(1 + flag) != null) if (elementsByClass.size() > (flag + 1) && elementsByClass.get(1 + flag) != null) {
                        Elements tdElements = elementsByClass.get(1 + flag).getElementsByTag("td");

                        // 客队赛前联赛积分排名数据
                        if (tdElements.size() > 1 && StringUtils.isNotBlank(tdElements.get(1).text())) {
                            String text33 = tdElements.get(1).text();
                            jsonObject.set("客队本赛季该赛事总计比赛次数", text33);
                        }
                        if (tdElements.size() > 2 && StringUtils.isNotBlank(tdElements.get(2).text())) {
                            String text34 = tdElements.get(2).text();
                            jsonObject.set("客队本赛季该赛事获胜比赛次数", text34);
                        }
                        if (tdElements.size() > 3 && StringUtils.isNotBlank(tdElements.get(3).text())) {
                            String text35 = tdElements.get(3).text();
                            jsonObject.set("客队本赛季该赛事平局比赛次数", text35);
                        }
                        if (tdElements.size() > 4 && StringUtils.isNotBlank(tdElements.get(4).text())) {
                            String text36 = tdElements.get(4).text();
                            jsonObject.set("客队本赛季该赛事输球比赛次数", text36);
                        }
                        if (tdElements.size() > 5 && StringUtils.isNotBlank(tdElements.get(5).text())) {
                            String text37 = tdElements.get(5).text();
                            jsonObject.set("客队本赛季该赛事进球数量", text37);
                        }
                        if (tdElements.size() > 6 && StringUtils.isNotBlank(tdElements.get(6).text())) {
                            String text38 = tdElements.get(6).text();
                            jsonObject.set("客队本赛季该赛事丢球数量", text38);
                        }
                        if (tdElements.size() > 7 && StringUtils.isNotBlank(tdElements.get(7).text())) {
                            String text39 = tdElements.get(7).text();
                            jsonObject.set("客队本赛季该赛事净胜球数量", text39);
                        }
                        if (tdElements.size() > 8 && StringUtils.isNotBlank(tdElements.get(8).text())) {
                            String text40 = tdElements.get(8).text();
                            jsonObject.set("客队本赛季该赛事目前积分", text40);
                        }
                        if (tdElements.size() > 9 && StringUtils.isNotBlank(tdElements.get(9).text())) {
                            String text41 = tdElements.get(9).text();
                            jsonObject.set("客队本赛季该赛事目前排名", text41);
                        }
                        if (tdElements.size() > 10 && StringUtils.isNotBlank(tdElements.get(10).text())) {
                            String text42 = tdElements.get(10).text();
                            jsonObject.set("客队本赛季该赛事胜率", text42);
                        }

                        // 客队主场数据
                        if (tdElements.size() > 12 && StringUtils.isNotBlank(tdElements.get(12).text())) {
                            String text43 = tdElements.get(12).text();
                            jsonObject.set("客队本赛季该赛事主场比赛次数", text43);
                        }
                        if (tdElements.size() > 13 && StringUtils.isNotBlank(tdElements.get(13).text())) {
                            String text44 = tdElements.get(13).text();
                            jsonObject.set("客队本赛季该赛事主场获胜次数", text44);
                        }
                        if (tdElements.size() > 14 && StringUtils.isNotBlank(tdElements.get(14).text())) {
                            String text45 = tdElements.get(14).text();
                            jsonObject.set("客队本赛季该赛事主场平局次数", text45);
                        }
                        if (tdElements.size() > 15 && StringUtils.isNotBlank(tdElements.get(15).text())) {
                            String text46 = tdElements.get(15).text();
                            jsonObject.set("客队本赛季该赛事主场输球次数", text46);
                        }
                        if (tdElements.size() > 16 && StringUtils.isNotBlank(tdElements.get(16).text())) {
                            String text47 = tdElements.get(16).text();
                            jsonObject.set("客队本赛季该赛事主场进球数量", text47);
                        }
                        if (tdElements.size() > 17 && StringUtils.isNotBlank(tdElements.get(17).text())) {
                            String text48 = tdElements.get(17).text();
                            jsonObject.set("客队本赛季该赛事主场丢球数量", text48);
                        }
                        if (tdElements.size() > 18 && StringUtils.isNotBlank(tdElements.get(18).text())) {
                            String text49 = tdElements.get(18).text();
                            jsonObject.set("客队本赛季该赛事主场净胜球数量", text49);
                        }
                        if (tdElements.size() > 21 && StringUtils.isNotBlank(tdElements.get(21).text())) {
                            String text50 = tdElements.get(21).text();
                            jsonObject.set("客队本赛季该赛事主场胜率", text50);
                        }

                        // 客队客场数据
                        if (tdElements.size() > 23 && StringUtils.isNotBlank(tdElements.get(23).text())) {
                            String text51 = tdElements.get(23).text();
                            jsonObject.set("客队本赛季该赛事客场比赛次数", text51);
                        }
                        if (tdElements.size() > 24 && StringUtils.isNotBlank(tdElements.get(24).text())) {
                            String text52 = tdElements.get(24).text();
                            jsonObject.set("客队本赛季该赛事客场获胜次数", text52);
                        }
                        if (tdElements.size() > 25 && StringUtils.isNotBlank(tdElements.get(25).text())) {
                            String text53 = tdElements.get(25).text();
                            jsonObject.set("客队本赛季该赛事客场平局次数", text53);
                        }
                        if (tdElements.size() > 26 && StringUtils.isNotBlank(tdElements.get(26).text())) {
                            String text54 = tdElements.get(26).text();
                            jsonObject.set("客队本赛季该赛事客场输球次数", text54);
                        }
                        if (tdElements.size() > 27 && StringUtils.isNotBlank(tdElements.get(27).text())) {
                            String text55 = tdElements.get(27).text();
                            jsonObject.set("客队本赛季该赛事客场进球数量", text55);
                        }
                        if (tdElements.size() > 28 && StringUtils.isNotBlank(tdElements.get(28).text())) {
                            String text56 = tdElements.get(28).text();
                            jsonObject.set("客队本赛季该赛事客场丢球数量", text56);
                        }
                        if (tdElements.size() > 29 && StringUtils.isNotBlank(tdElements.get(29).text())) {
                            String text57 = tdElements.get(29).text();
                            jsonObject.set("客队本赛季该赛事客场净胜球数量", text57);
                        }
                        if (tdElements.size() > 32 && StringUtils.isNotBlank(tdElements.get(32).text())) {
                            String text58 = tdElements.get(32).text();
                            jsonObject.set("客队本赛季该赛事客场胜率", text58);
                        }
                    }

                    if (shujuOdds.getElementsByClass("his_info").size() > 0) {
                        //        双方交手历史战绩，(以主队视角而论)
//                        String winHis = shujuOdds.getElementsByClass("f16").get(0).getElementsByTag("em").get(0).text();
//                        String drawHis = shujuOdds.getElementsByClass("f16").get(0).getElementsByTag("em").get(1).text();
//                        String loseHis = shujuOdds.getElementsByClass("f16").get(0).getElementsByTag("em").get(2).text();
                        if (StringUtils.isNotBlank(shujuOdds.getElementsByClass("his_info").text())) {
                            jsonObject.set("双方交战历史", shujuOdds.getElementsByClass("his_info").text());
                        }
                    }

                    if (shujuOdds.getElementsByClass("dz").size() > 0) {
                        if (shujuOdds.getElementsByClass("dz").size() > 4) {
                            if ("主队比分客队".equals(shujuOdds.getElementsByClass("dz").get(0).text())) {
                                String dz1 = shujuOdds.getElementsByClass("dz").get(2).text();
                                String dz2 = shujuOdds.getElementsByClass("dz").get(3).text();
                                if (StringUtils.isNotBlank(dz1) && StringUtils.isNotBlank(dz2)) {
                                    if (dz1.matches(".*\\d.*") && dz2.matches(".*\\d.*")) {
                                        jsonObject.set("双方历史交锋记录", dz1.replaceAll("\\[\\d+]", "") + "," + dz2.replaceAll("\\[\\d+]", ""));
                                    } else {
                                        playInfoPO.setPredictResultAsian("数据不完整,不建议投资");
                                    }
                                } else {
                                    playInfoPO.setPredictResultAsian("数据不完整,不建议投资");
                                }
                            } else {
                                playInfoPO.setPredictResultAsian("数据不完整,不建议投资");
                            }
                        } else {
                            playInfoPO.setPredictResultAsian("数据不完整,不建议投资");
                        }
                        if (shujuOdds.getElementsByClass("dz").size() > 1) {
                            for (int j = 1; j < shujuOdds.getElementsByClass("dz").size(); j++) {
    //                        跳过第一场开始循环，如果后面再有客队的数据就动态塞入
                                if ("主队比分客队".equals(shujuOdds.getElementsByClass("dz").get(j).text())) {
                                    if (shujuOdds.getElementsByClass("dz").size() >= (j + 7)) {
                                        String dz1 = shujuOdds.getElementsByClass("dz").get(j + 2).text();
                                        String dz2 = shujuOdds.getElementsByClass("dz").get(j + 3).text();
                                        String dz3 = shujuOdds.getElementsByClass("dz").get(j + 4).text();
                                        String dz4 = shujuOdds.getElementsByClass("dz").get(j + 5).text();
                                        String dz5 = shujuOdds.getElementsByClass("dz").get(j + 6).text();
                                        if (StringUtils.isNotBlank(dz1) && StringUtils.isNotBlank(dz2) && StringUtils.isNotBlank(dz3) && StringUtils.isNotBlank(dz4) && StringUtils.isNotBlank(dz5)) {
                                            if (dz1.matches(".*\\d.*") && dz2.matches(".*\\d.*") && dz3.matches(".*\\d.*") && dz4.matches(".*\\d.*") && dz5.matches(".*\\d.*")) {
                                                if(jsonObject.containsKey("两队近期表现")){
                                                    jsonObject.set("两队近期表现",jsonObject.get("两队近期表现") + "," + dz1.replaceAll("\\[\\d+]", "") + "," + dz2.replaceAll("\\[\\d+]", "") + "," + dz3.replaceAll("\\[\\d+]", "") + "," + dz4.replaceAll("\\[\\d+]", "") + "," + dz5.replaceAll("\\[\\d+]", ""));
                                                    break;
                                                }else{
                                                    jsonObject.set("两队近期表现",dz1.replaceAll("\\[\\d+]", "") + "," + dz2.replaceAll("\\[\\d+]", "") + "," + dz3.replaceAll("\\[\\d+]", "") + "," + dz4.replaceAll("\\[\\d+]", "") + "," + dz5.replaceAll("\\[\\d+]", ""));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (!jsonObject.containsKey("两队近期表现")) {
                            playInfoPO.setPredictResultAsian("数据不完整,不建议投资");
                        }
                    }

//                    if (shujuOdds.getElementsByClass("bottom_info").size() > 0) {
//                        //        主队多少胜,平，负
//                        if (StringUtils.isNotBlank(shujuOdds.getElementsByClass("bottom_info").get(0).getElementsByTag("p").text())) {
//                            jsonObject.set("主队最近战绩", shujuOdds.getElementsByClass("bottom_info").get(0).getElementsByTag("p").text());
//                        }
//                    }
//                    if (shujuOdds.getElementsByClass("bottom_info").size() > 1) {
//                        //        客队多少胜,平，负
//                        if (StringUtils.isNotBlank(shujuOdds.getElementsByClass("bottom_info").get(1).getElementsByTag("p").text())) {
//                            jsonObject.set("客队最近战绩", shujuOdds.getElementsByClass("bottom_info").get(1).getElementsByTag("p").text());
//                        }
//                    }

                    Document shujuOdds6 = null;
                    try {
                        Connection conn6 = Jsoup.connect("https://odds.500.com/fenxi/touzhu-" + id + ".shtml").timeout(30000);
                        conn6.maxBodySize(0);
                        conn6.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn6.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn6.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn6.header("User-Agent", "Mozilla");
                        shujuOdds6 = conn6.get();
                    } catch (IOException e) {
                        log.error("https://odds.500.com/fenxi/touzhu-" + id + ".shtml" + "无法访问,暂时跳过");
                        log.error(e.getMessage());
                        playInfoPO.setDetailInfo(jsonObject.toString());
                        updatePlayList.add(playInfoPO);
                        continue;
                    }
                    Elements elementsByClass6 = shujuOdds6.getElementsByClass("pub_table pl_table_data  bif-yab");
                    if (elementsByClass6.get(0) != null) {
    //                    主胜冷热指数
                        String homeHot = elementsByClass6.get(0).getElementsByTag("td").get(20).text();
    //                    平局冷热指数
                        String drawHot = elementsByClass6.get(0).getElementsByTag("td").get(31).text();
    //                    客胜冷热指数
                        String visitHot = elementsByClass6.get(0).getElementsByTag("td").get(42).text();
                        if (StringUtils.isNotBlank(homeHot) && !"-".equals(homeHot)) {
                            jsonObject.set("主胜冷热指数", homeHot);
                        }
                        if (StringUtils.isNotBlank(drawHot) && !"-".equals(drawHot)) {
                            jsonObject.set("平局冷热指数", drawHot);
                        }
                        if (StringUtils.isNotBlank(visitHot) && !"-".equals(visitHot)) {
                            jsonObject.set("客胜冷热指数", visitHot);
                        }
                    }
                    if (elementsByClass6.size() > 1) {
                        if (elementsByClass6.get(1) != null) {
                            Elements tdList2 = elementsByClass6.get(1).getElementsByTag("td");
                            List<HotTransactionVo> voList = new ArrayList<>();
                            for (int j = 0; j < tdList2.size(); j++) {
                                if ((j + 1) % 5 == 0) {
                                    HotTransactionVo vo = new HotTransactionVo();
                                    vo.setPurchaseDirection(tdList2.get(j - 4).text());
                                    vo.setBuyOrSell(tdList2.get(j - 3).text());
                                    vo.setTurnover(tdList2.get(j - 2).text());
                                    vo.setTradingTime(tdList2.get(j - 1).text());
                                    vo.setTransactionRatio(tdList2.get(j).text());
                                    voList.add(vo);
                                }
                            }
                            jsonObject.set("必发大额购买方向", voList);
                        }
                    }
                    Elements elementsByClass7 = shujuOdds6.getElementsByClass("data-detail");
    //                大额交易量
                    if (elementsByClass7.size() > 1 && elementsByClass7.get(1) != null) {
                        Elements liList = elementsByClass7.get(1).getElementsByTag("li");
                        jsonObject.set("主胜大额交易量", liList.get(0));
                        jsonObject.set("平局大额交易量", liList.get(1));
                        jsonObject.set("客胜大额交易量", liList.get(2));
                    }

                    String teamUrl1 = "https:" + tdList.get(5).getElementsByTag("a").attr("href");//主队身价
                    String teamUrl2 = "https:" + tdList.get(7).getElementsByTag("a").attr("href");//客队身价

                    Document shujuOdds7 = null;
                    try {
                        Connection conn7 = Jsoup.connect(teamUrl1).timeout(30000);
                        conn7.maxBodySize(0);
                        conn7.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn7.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn7.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn7.header("User-Agent", "Mozilla");
                        shujuOdds7 = conn7.get();
                    } catch (IOException e) {
                        log.error("身价网址url无法访问,暂时跳过");
                        log.error(e.getMessage());
                        playInfoPO.setDetailInfo(jsonObject.toString());
                        updatePlayList.add(playInfoPO);
                        continue;
                    }
                    Elements elementsByClass1 = shujuOdds7.getElementsByClass("itm_bd");
                    String homeValue = elementsByClass1.get(0).getElementsByTag("td").get(5).text().substring(5);

                    Document shujuOdds8 = null;
                    try {
                        Connection conn8 = Jsoup.connect(teamUrl2).timeout(30000);
                        conn8.maxBodySize(0);
                        conn8.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn8.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn8.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn8.header("User-Agent", "Mozilla");
                        shujuOdds8 = conn8.get();
                    } catch (IOException e) {
                        log.error("身价网址url无法访问,暂时跳过");
                        log.error(e.getMessage());
                        playInfoPO.setDetailInfo(jsonObject.toString());
                        updatePlayList.add(playInfoPO);
                        continue;
                    }
                    Elements elementsByClass2 = shujuOdds8.getElementsByClass("itm_bd");

                    String visitValue = elementsByClass2.get(0).getElementsByTag("td").get(5).text().substring(5);

                    if (!"--".equals(homeValue) && !"--".equals(visitValue)) {
                        jsonObject.set("主队身价", homeValue);
                        jsonObject.set("客队身价", visitValue);
                    }
                    playInfoPO.setDetailInfo(jsonObject.toString());
                    updatePlayList.add(playInfoPO);
                }
            }

//         后几天的数据
            StringBuilder a = new StringBuilder("https://live.500.com/weekfixture.php?e=");
            for (int k = 1; k < 3; k++) {
                a.append(k);
                Document document1 = null;
                try {
                    Connection conn8 = Jsoup.connect(a.toString()).timeout(10000);
                    conn8.maxBodySize(0);
                    conn8.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                    conn8.header("Accept-Encoding", "gzip, deflate, sdch");
                    conn8.header("Accept-Language", "zh-CN,zh;q=0.8");
                    conn8.header("User-Agent", "Mozilla");
                    //          获取真实的数据体
                    document1 = conn8.get();
                } catch (IOException e) {
                    log.error(a.toString() + "无法访问,暂时跳过");
                    log.error(e.getMessage());
                    continue;
                }

                Elements trList2 = document1.getElementById("table_match").getElementsByTag("tr");

                //        从第2个开始，第1个数据没用
                big:
                for (int i = 1; i < trList2.size(); i++) {
                    Element idEl = trList2.get(i);
                    String idStr = idEl.toString();
    //            没有id说明已经到了加时赛的数据，先不爬取,直接退出
                    if (!idStr.contains("id")) {
                        continue;
                    }
                    Elements tdList = trList2.get(i).getElementsByTag("td");
                    if (StringUtils.isBlank(trList2.get(i).id())) {
                        continue;
                    }

    //            先查询是否添加过该条比赛信息
                    LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getEventName, tdList.get(0).getElementsByTag("a").text());
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getHomeName, tdList.get(3).getElementsByTag("a").text());
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getVisitName, tdList.get(5).getElementsByTag("a").text());
    //            本年

                    String time = tdList.get(2).text();
                    DateTime timeParse = DateUtil.parse(yearInt + " " + time, "yyyy MM-dd HH:mm");
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getPlayingTime, timeParse);//如果比赛时间被后期推迟修改，则可能会多出来一条数据，无所谓。
    //            playInfoPOLambdaQueryWrapper.select(PlayInfoPO::getId);
                    List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
                    PlayInfoPO playInfoPO = null;
                    if (playInfoPOS == null || playInfoPOS.size() == 0) {
                        //                赛事名称
                        playInfoPO = new PlayInfoPO();
                        playInfoPO.setEventName(tdList.get(0).getElementsByTag("a").text());
    //                比赛时间
                        playInfoPO.setPlayingTime(timeParse);

                        //                主队名称
                        playInfoPO.setHomeName(tdList.get(3).getElementsByTag("a").text());

                        playInfoPO.setHomeScore(0);
                        playInfoPO.setVisitScore(0);
    //                客队名称
                        playInfoPO.setVisitName(tdList.get(5).getElementsByTag("a").text());
                        playInfoService.save(playInfoPO);
    //                    insertPlayList.add(playInfoPO);
                    } else {
                        playInfoPO = playInfoPOS.get(0);
                    }

    //            找到该条数据id，然后进入亚赔页面
                    String id = idStr.substring(idStr.indexOf("id=\"") + 5, idStr.indexOf("id=\"") + 12);

    //                    进入亚赔 ↓↓↓↓↓↓↓↓↓↓↓↓
                    Document asianOdds = null;
                    try {
                        Connection conn2 = Jsoup.connect("https://odds.500.com/fenxi/yazhi-" + id + ".shtml").timeout(30000);
                        conn2.maxBodySize(0);
                        conn2.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn2.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn2.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn2.header("User-Agent", "Mozilla");
                        asianOdds = conn2.get();
                    } catch (IOException e) {
                        log.error("https://odds.500.com/fenxi/yazhi-" + id + ".shtml" + "无法访问,暂时跳过");
                        log.error(e.getMessage());
                        continue;
                    }
                    Element datatb = asianOdds.getElementById("datatb");
                    Elements asianTrList1 = datatb.getElementsByClass("tr1");
                    Elements asianTrList2 = datatb.getElementsByClass("tr2");
    //                    二合一
                    asianTrList1.addAll(asianTrList2);
    //                二合一后,拿所有公司，不止是主流
                    Elements mostEleList = new Elements();
                    for (Element element1 : asianTrList1
                    ) {
                        Elements src1 = element1.getElementsByAttributeValue("src", "/images/oz_zhu.gif");
                        if (src1.size() != 0) {
                            mostEleList.add(element1);
                        }
                    }
    //                    对每条庄家数据进行循环
                    for (Element tr : mostEleList
                    ) {
    //                        会有2个class叫: pl_table_data的属性,一个初盘一个即盘
                        Elements plTableData = tr.getElementsByClass("pl_table_data");
    //                        即时盘口的td标签数据
                        Elements td = plTableData.get(0).getElementsByTag("td");
    //                        初始盘口的td标签数据
                        Elements td2 = plTableData.get(1).getElementsByTag("td");
    //                        即时主队盘口赔率
                        String homeDrib = td.get(0).text();
    //                        即时主队盘口让球情况
                        String homeDribName = td.get(1).text();
    //                        即时客队盘口赔率
                        String visitDrib = td.get(2).text();

    //                        初始主队盘口赔率
                        String homeDrib2 = td2.get(0).text();
    //                        初始主队盘口让球情况
                        String homeDrib2Name = td2.get(1).text();
    //                        初始客队盘口赔率
                        String visitDrib2 = td2.get(2).text();

                        Elements tbPlgs = tr.getElementsByClass("tb_plgs");
                        //                        赔率公司名称
                        Elements quancheng = tbPlgs.get(0).getElementsByClass("quancheng");

                        //                            查看有无初盘数据，无则添加
                        LambdaQueryWrapper<AsianBankerInfoPO> bankerInfoPOLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getBankerName, quancheng.text());
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getStartNowHandicapFlag, "0");//初盘
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getHomeHandicap, new BigDecimal(homeDrib2));
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getVisitHandicap, new BigDecimal(visitDrib2));
                        DateTime timeParse3 = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(12).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");
                        bankerInfoPOLambdaQueryWrapper2.eq(AsianBankerInfoPO::getCreateTime, timeParse3);
                        List<AsianBankerInfoPO> asianBankerInfoPOS2 = asianBankerInfoMapper.selectList(bankerInfoPOLambdaQueryWrapper2);
    //                            如果没添加过再添加
                        if (asianBankerInfoPOS2 == null || asianBankerInfoPOS2.size() == 0) {
    //                            添加初始数据
                            AsianBankerInfoPO asianBankerInfoPO = new AsianBankerInfoPO();
                            asianBankerInfoPO.setBankerName(quancheng.text());
                            asianBankerInfoPO.setPlayInfoId(playInfoPO.getId());
                            asianBankerInfoPO.setHomeHandicap(new BigDecimal(homeDrib2));
                            asianBankerInfoPO.setVisitHandicap(new BigDecimal(visitDrib2));
                            asianBankerInfoPO.setStartNowHandicapFlag("0");// 0: 初盘
                            asianBankerInfoPO.setCreateTime(timeParse3);
                            asianBankerInfoPO.setHandicapName(homeDrib2Name);
                            insertAsianList.add(asianBankerInfoPO);
                        } else {
                            homeDrib = homeDrib.replaceAll("↑", "").replaceAll("↓", "");
                            visitDrib = visitDrib.replaceAll("↑", "").replaceAll("↓", "");
                            //                        看同一时间同一庄家同一场比赛的即盘数据是否存在，只有在相同时间和相同赔率的情况下不需要新增数据。说明没有更新数据。
                            LambdaQueryWrapper<AsianBankerInfoPO> bankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getBankerName, quancheng.text());
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getStartNowHandicapFlag, "1");//即盘
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getHomeHandicap, new BigDecimal(homeDrib));
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getVisitHandicap, new BigDecimal(visitDrib));
                            DateTime timeParse2 = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(7).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");
                            bankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getCreateTime, timeParse2);

                            List<AsianBankerInfoPO> asianBankerInfoPOS = asianBankerInfoMapper.selectList(bankerInfoPOLambdaQueryWrapper);
                            if (asianBankerInfoPOS == null || asianBankerInfoPOS.size() == 0) {
    //                            添加即时的盘口数据
                                AsianBankerInfoPO asianBankerInfoPO = new AsianBankerInfoPO();
                                asianBankerInfoPO.setBankerName(quancheng.text());
                                asianBankerInfoPO.setPlayInfoId(playInfoPO.getId());
    //                            箭头符号删除掉
                                asianBankerInfoPO.setHomeHandicap(new BigDecimal(homeDrib));
                                asianBankerInfoPO.setVisitHandicap(new BigDecimal(visitDrib));
                                asianBankerInfoPO.setStartNowHandicapFlag("1");// 1: 即盘
                                asianBankerInfoPO.setCreateTime(timeParse2);
                                asianBankerInfoPO.setHandicapName(homeDribName);
                                insertAsianList.add(asianBankerInfoPO);
    //                        asianBankerInfoMapper.insert(asianBankerInfoPO);
                            }
                        }
                    }

    //                    进入欧赔↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
                    Document europeOdds = null;
                    try {
                        Connection conn3 = Jsoup.connect("https://odds.500.com/fenxi/ouzhi-" + id + ".shtml").timeout(30000);
                        conn3.maxBodySize(0);
                        conn3.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn3.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn3.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn3.header("User-Agent", "Mozilla");
                        europeOdds = conn3.get();
                    } catch (IOException e) {
                        log.error("https://odds.500.com/fenxi/ouzhi-" + id + ".shtml" + "无法访问,暂时跳过");
                        log.error(e.getMessage());
                        continue;
                    }
                    Element datatb2 = europeOdds.getElementById("datatb");
                    Elements europeTrList1 = datatb2.getElementsByClass("tr1");
                    Elements europeTrList2 = datatb2.getElementsByClass("tr2");
                    //                    二合一
                    europeTrList1.addAll(europeTrList2);
                    //                二合一后把所有主流公司筛选出来
                    Elements mostEleList2 = new Elements();
                    for (Element element1 : europeTrList1
                    ) {
                        Elements src1 = element1.getElementsByAttributeValue("src", "/images/oz_zhu.gif");
                        if (src1.size() != 0) {
                            mostEleList2.add(element1);
                        }
                    }
    //                    对每条庄家数据进行循环
                    for (Element tr : mostEleList2
                    ) {
                        Elements plTableData = tr.getElementsByClass("pl_table_data");
                        Elements td = plTableData.get(0).getElementsByTag("td");
    //                        初盘主队赔率
                        Element winTd1 = td.get(0);
                        Element drawTd1 = td.get(1);
                        Element loseTd1 = td.get(2);
    //                        即盘主队赔率
                        Element winTd2 = td.get(3);
                        Element drawTd2 = td.get(4);
                        Element loseTd2 = td.get(5);

                        Elements tbPlgs = tr.getElementsByClass("tb_plgs");
    //                        赔率公司名称
                        Elements quancheng = tbPlgs.get(0).getElementsByClass("quancheng");
                        Date nowDate = new Date();
    //                        DateTime dateTime = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(12).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");

                        LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getBankerName, quancheng.text());
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeWinHandicap, new BigDecimal(winTd1.text()));
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeDrawHandicap, new BigDecimal(drawTd1.text()));
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeLoseHandicap, new BigDecimal(loseTd1.text()));
                        europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getStartNowHandicapFlag, "0");
    //                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getCreateTime, nowDate);
                        List<EuropeBankerInfoPO> europeBankerInfoPOList = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper);
    //                        初盘没数据的话则添加一条！
                        if (europeBankerInfoPOList == null || europeBankerInfoPOList.size() == 0) {
                            EuropeBankerInfoPO europeBankerInfoPO = new EuropeBankerInfoPO();
                            europeBankerInfoPO.setBankerName(quancheng.text());
                            europeBankerInfoPO.setHomeWinHandicap(new BigDecimal(winTd1.text()));
                            europeBankerInfoPO.setHomeDrawHandicap(new BigDecimal(drawTd1.text()));
                            europeBankerInfoPO.setHomeLoseHandicap(new BigDecimal(loseTd1.text()));
    //                            添加即时数据
                            europeBankerInfoPO.setPlayInfoId(playInfoPO.getId());
                            europeBankerInfoPO.setStartNowHandicapFlag("0");// 0: 初盘
                            europeBankerInfoPO.setCreateTime(nowDate);//拿不到准确时间，就拿现在的机器时间即可。
                            insertEuropeList.add(europeBankerInfoPO);
                        } else {
    //                            初盘有数据，看下即盘
                            LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getBankerName, quancheng.text());
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeWinHandicap, new BigDecimal(winTd2.text()));
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeDrawHandicap, new BigDecimal(drawTd2.text()));
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeLoseHandicap, new BigDecimal(loseTd2.text()));
                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getStartNowHandicapFlag, "1");
    //                            如果水位没变化，就算时间变了也不管，没事，防止重复添加数据，因为时间永远是即时的时间
    //                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getCreateTime, nowDate);
                            List<EuropeBankerInfoPO> europeBankerInfoPOList2 = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper2);
    //                            没有即盘数据则添加，有可能是发生了变化，继续添加即可。
                            if (europeBankerInfoPOList2 == null || europeBankerInfoPOList2.size() == 0) {
                                EuropeBankerInfoPO europeBankerInfoPO = new EuropeBankerInfoPO();
                                europeBankerInfoPO.setBankerName(quancheng.text());
                                europeBankerInfoPO.setHomeWinHandicap(new BigDecimal(winTd2.text()));
                                europeBankerInfoPO.setHomeDrawHandicap(new BigDecimal(drawTd2.text()));
                                europeBankerInfoPO.setHomeLoseHandicap(new BigDecimal(loseTd2.text()));
    //                            添加即时数据
                                europeBankerInfoPO.setPlayInfoId(playInfoPO.getId());
                                europeBankerInfoPO.setStartNowHandicapFlag("1");// 1: 即盘
                                europeBankerInfoPO.setCreateTime(nowDate);
                                insertEuropeList.add(europeBankerInfoPO);
                            }
                        }
                    }

    //              进入大小球↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
                    Document europeOdds2 = null;
                    try {
                        Connection conn4 = Jsoup.connect("https://odds.500.com/fenxi/daxiao-" + id + ".shtml").timeout(30000);
                        conn4.maxBodySize(0);
                        conn4.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                        conn4.header("Accept-Encoding", "gzip, deflate, sdch");
                        conn4.header("Accept-Language", "zh-CN,zh;q=0.8");
                        conn4.header("User-Agent", "Mozilla");
                        europeOdds2 = conn4.get();
                    } catch (IOException e) {
                        log.error("https://odds.500.com/fenxi/daxiao-" + id + ".shtml" + "无法访问,暂时跳过");
                        log.error(e.getMessage());
                        continue;
                    }
                    Element datatb3 = europeOdds2.getElementById("datatb");
                    Elements europeTrList3 = datatb3.getElementsByClass("tr1");
                    Elements europeTrList4 = datatb3.getElementsByClass("tr2");
                    //                    二合一
                    europeTrList3.addAll(europeTrList4);
                    //                二合一后把所有主流公司筛选出来
                    Elements mostEleList3 = new Elements();
                    for (Element element1 : europeTrList3
                    ) {
                        Elements src1 = element1.getElementsByAttributeValue("src", "/images/oz_zhu.gif");
                        if (src1.size() != 0) {
                            mostEleList3.add(element1);
                        }
                    }
    //                    对每条庄家数据进行循环
                    for (Element tr : mostEleList3
                    ) {
                        Elements plTableData = tr.getElementsByClass("pl_table_data");
                        Elements td = plTableData.get(0).getElementsByTag("td");

    //                        即盘大小球赔率
                        Element newBig = td.get(0);
                        Element newHandcapName = td.get(1);//即盘的大小球盘口值
                        Element newSmall = td.get(2);

                        Elements td2 = plTableData.get(1).getElementsByTag("td");
    //                        初盘大小球赔率
                        Element oldBig = td2.get(0);
                        Element oldHandcapName = td2.get(1);//初盘的大小球盘口值
                        Element oldSmall = td2.get(2);

                        Elements tbPlgs = tr.getElementsByClass("tb_plgs");
    //                        赔率公司名称
                        Elements quancheng = tbPlgs.get(0).getElementsByClass("quancheng");

    //                    初盘盘口的时间
                        DateTime dateTime = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(12).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");
                        LambdaQueryWrapper<BigSmallInfo> bigSmallInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getPlayInfoId, playInfoPO.getId());
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getBankerName, quancheng.text());
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getBigHandicap, new BigDecimal(oldBig.text().replaceAll("↑", "").replaceAll("↓", "")));
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getSmallHandicap, new BigDecimal(oldSmall.text().replaceAll("↑", "").replaceAll("↓", "")));
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getHandicapName, oldHandcapName.text().replaceAll("↑", "").replaceAll("↓", ""));
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getStartNowHandicapFlag, "0");
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getCreateTime, dateTime);
                        List<BigSmallInfo> bigSmallInfoList = bigSmallInfoMapper.selectList(bigSmallInfoLambdaQueryWrapper);

    //                        初盘没数据的话则添加一条！
                        if (bigSmallInfoList == null || bigSmallInfoList.size() == 0) {
                            BigSmallInfo bigSmallInfo = new BigSmallInfo();
                            bigSmallInfo.setBankerName(quancheng.text());
                            bigSmallInfo.setBigHandicap(new BigDecimal(oldBig.text().replaceAll("↑", "").replaceAll("↓", "")));
                            bigSmallInfo.setSmallHandicap(new BigDecimal(oldSmall.text().replaceAll("↑", "").replaceAll("↓", "")));
                            bigSmallInfo.setHandicapName(oldHandcapName.text().replaceAll("↑", "").replaceAll("↓", ""));
    //                            添加即时数据
                            bigSmallInfo.setPlayInfoId(playInfoPO.getId());
                            bigSmallInfo.setStartNowHandicapFlag("0");// 0: 初盘
                            bigSmallInfo.setCreateTime(dateTime);
                            insertBigSmallInfoList.add(bigSmallInfo);
                        } else {
    //                            初盘有数据，看下即盘
                            DateTime dateTime2 = DateUtil.parse(yearInt + " " + tr.getElementsByTag("td").get(7).getElementsByTag("time").text(), "yyyy MM-dd HH:mm");

                            LambdaQueryWrapper<BigSmallInfo> bigSmallInfoLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getPlayInfoId, playInfoPO.getId());
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getBankerName, quancheng.text());
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getBigHandicap, new BigDecimal(newBig.text().replaceAll("↑", "").replaceAll("↓", "")));
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getSmallHandicap, new BigDecimal(newSmall.text().replaceAll("↑", "").replaceAll("↓", "")));
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getStartNowHandicapFlag, "1");
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getHandicapName, newHandcapName.text().replaceAll("↑", "").replaceAll("↓", ""));
                            bigSmallInfoLambdaQueryWrapper2.eq(BigSmallInfo::getCreateTime, dateTime2);
                            List<BigSmallInfo> bigSmallInfoList2 = bigSmallInfoMapper.selectList(bigSmallInfoLambdaQueryWrapper2);
    //                            没有即盘数据则添加，有可能是发生了变化，继续添加即可。
                            if (bigSmallInfoList2 == null || bigSmallInfoList2.size() == 0) {
                                BigSmallInfo bigSmallInfo = new BigSmallInfo();
                                bigSmallInfo.setBankerName(quancheng.text());
                                bigSmallInfo.setBigHandicap(new BigDecimal(newBig.text().replaceAll("↑", "").replaceAll("↓", "")));
                                bigSmallInfo.setSmallHandicap(new BigDecimal(newSmall.text().replaceAll("↑", "").replaceAll("↓", "")));
                                bigSmallInfo.setHandicapName(newHandcapName.text().replaceAll("↑", "").replaceAll("↓", ""));
    //                            添加即时数据
                                bigSmallInfo.setPlayInfoId(playInfoPO.getId());
                                bigSmallInfo.setStartNowHandicapFlag("1");// 1: 即盘
                                bigSmallInfo.setCreateTime(dateTime2);
                                insertBigSmallInfoList.add(bigSmallInfo);
                            }
                        }
                    }

                }
            }
        playInfoService.updateBatchById(updatePlayList);
        asianBankerInfoService.saveBatch(insertAsianList);
        europeBankerInfoService.saveBatch(insertEuropeList);
        bigSmallInfoService.saveBatch(insertBigSmallInfoList);
        log.warn("爬取结束,数据抓取完毕---------------------------------");
    }


    /**
     * 自动拉取数据和更新数据(国外版)
     */
//    @Scheduled(cron = "0 0/1 * * * ?") //每2分钟自动执行一次
    @Transactional
    public void autoGetAndUpdateInfo2() throws Exception {
        log.error("开始拉取国外数据");
        Date nowDate = new Date();
//        每一天的比赛
//        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("47.94.156.48", 7890));
        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));

        Connection.Response response = null;
        try {
            response = Jsoup.connect("https://www.footballant.cn/matches/" + DateUtil.format(nowDate, "yyyy-MM-dd"))
//                    .ignoreContentType(true)
                    .header("Content-Type", "application/x-www-form-urlencoded")
                    .userAgent("Mozilla")
                    .referrer("http://www.youtube.com")
                    .timeout(30000)
                    .followRedirects(true)
                    .proxy(proxy)
                    .execute();
        } catch (IOException e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }
        if (response != null) {
            Document document = response.parse();

            //获取真实的数据体
            Elements bigElementList = document.getElementsByClass("matchDiv matchDiv2");
            Element bigDiv = bigElementList.get(0);
            Elements matchInfo = bigDiv.getElementsByClass("matchInfo");


//        List<PlayInfoPO> insertPlayList = new ArrayList<>();
            List<PlayInfoPO> updatePlayList = new ArrayList<>();
//        List<AsianBankerInfoPO> insertAsianList = new ArrayList<>();
            List<EuropeBankerInfoPO> insertEuropeList = new ArrayList<>();
//        从第2个开始，第1个数据没用
//            todo:不能只弄5场，这里要改，同时进行的比赛有很多,但是能不能弄到是个问题。
            for (int i = 0; i < 5; i++) {
                Element match = matchInfo.get(i);
                Elements divList = match.getElementsByTag("div");
                String eventName = divList.get(0).getElementsByTag("a").get(0).text();
                Elements homeVistName = match.getElementsByClass("el-col el-col-24 el-col-xs-15 el-col-sm-18 text-left");
                String homeName = homeVistName.get(0).getElementsByTag("a").get(0).text();
                String hrefV = homeVistName.get(0).getElementsByTag("a").get(0).attributes().get("href");
//            页面跳转附参id
                String idStr = hrefV.substring(hrefV.lastIndexOf("/") + 1);
//            href="/matches/2487579" title="西悉尼流浪者女足" target="_blank" data-v-1cf89ff6
                String visitName = homeVistName.get(0).getElementsByTag("a").get(1).text();


                Elements matchTimes = match.getElementsByClass("el-col el-col-24 el-col-xs-3 el-col-sm-2 time font-12 text-center");
//            没开始的时候，matchTime是月份+天，开始后上面是小时+分钟数
                String matchTime = matchTimes.get(0).getElementsByClass("numFont").get(0).text();
//            没开始的时候matchTime2是小时+分钟数，开始后是当前比赛进行到第几分钟

                //            本年
                int yearInt = DateUtil.thisYear();
                PlayInfoPO playInfoPO = null;
//            没开始的比赛↓
                if (matchTimes.get(0).getElementsByClass("text-color-green text-ellipsis").size() != 0) {
                    String matchTime2 = matchTimes.get(0).getElementsByClass("text-color-green text-ellipsis").get(0).text();
//                if(matchTime.contains("-")){
                    //            先查询是否添加过该条比赛信息
                    LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getEventName, eventName);
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getHomeName, homeName);
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getVisitName, visitName);
//                包括'-'符号就是还没开赛，包括':'符号就是已经开始踢了
                    DateTime timeParse = DateUtil.parse(yearInt + " " + matchTime + " " + matchTime2, "yyyy MM-dd HH:mm");
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getPlayingTime, timeParse);//如果比赛时间被后期推迟修改，则可能会多出来一条数据，无所谓。
                    List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
                    if (playInfoPOS == null || playInfoPOS.size() == 0) {
                        //                赛事名称
                        playInfoPO = new PlayInfoPO();
                        playInfoPO.setEventName(eventName);
//                比赛时间
                        playInfoPO.setPlayingTime(timeParse);
//                主队名称
                        playInfoPO.setHomeName(homeName);
////                客队名称
                        playInfoPO.setVisitName(visitName);
                        playInfoPO.setPlayingTime(timeParse);
//                        insertPlayList.add(playInfoPO);
                        playInfoMapper.insert(playInfoPO);
                    } else {
                        playInfoPO = playInfoPOS.get(0);
                    }
//                    }
                } else {
//                更新比赛进球数量
                    LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getEventName, eventName);
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getHomeName, homeName);
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getVisitName, visitName);
                    DateTime timeParse = DateUtil.parse(yearInt + " " + (DateUtil.month(nowDate) + 1) + "-" + DateUtil.dayOfMonth(nowDate) + " " + matchTime, "yyyy MM-dd HH:mm");
                    playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getPlayingTime, timeParse);
                    playInfoPOLambdaQueryWrapper.orderByDesc(PlayInfoPO::getPlayingTime);//倒序，防止这2个队以前踢过比赛，就拿最新的进行更新就对了。
                    List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
                    if (playInfoPOS == null || playInfoPOS.size() == 0) {
                        playInfoPO = new PlayInfoPO();
                        playInfoPO.setEventName(eventName);
//                比赛时间
                        playInfoPO.setPlayingTime(timeParse);
//                主队名称
                        playInfoPO.setHomeName(homeName);
////                客队名称
                        playInfoPO.setVisitName(visitName);
                        playInfoPO.setPlayingTime(timeParse);
//                        insertPlayList.add(playInfoPO);
                        playInfoMapper.insert(playInfoPO);
                    } else {
                        Elements scoreTag = match.getElementsByClass("scores").get(0).getElementsByTag("strong");
                        String homeScore = scoreTag.get(0).text();
                        String visitScore = scoreTag.get(1).text();
                        playInfoPO = playInfoPOS.get(0);
                        playInfoPO.setHomeScore(Integer.parseInt(homeScore));
//                当前客队比分
                        playInfoPO.setVisitScore(Integer.parseInt(visitScore));
//                比分可以后面再更新，insert是必须马上，不然后面没有id对应了
                        updatePlayList.add(playInfoPO);
                    }
                }
//                    进入欧赔↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
                Connection.Response response2 = null;
                try {
                    response2 = Jsoup.connect("https://www.footballant.cn/matches/" + idStr + "/odds")
                            .ignoreContentType(true)
                            .userAgent("Mozilla/4.0 compatible FurlBot/Furl Search 2.0 (FurlBot; http://www.furl.net; wn.furlbot@looksmart.net)")
                            .referrer("http://www.youtube.com")
                            .timeout(30000)
                            .proxy(proxy)
                            .followRedirects(true)
                            .execute();
                } catch (IOException e) {
                    log.error(e.getMessage());
                }
                if (response2 != null) {
                    Document europeOdds = response2.parse();
                    Elements hrefs = europeOdds.getElementsByClass("input-xs").get(0).getElementsByAttribute("href");
                    for (Element element1 : hrefs
                    ) {
                        String hrefId = element1.attributes().get("href");
//                庄家名(带星号)
                        String quancheng = element1.text();
//                取得每个欧盘的id
                        Connection.Response response3 = null;
                        try {
                            response3 = Jsoup.connect("https://www.footballant.cn/matches/" + idStr + "/odds?id=" + hrefId.substring(hrefId.indexOf("id=") + 3))
                                    .ignoreContentType(true)
                                    .userAgent("Mozilla/4.0 compatible FurlBot/Furl Search 2.0 (FurlBot; http://www.furl.net; wn.furlbot@looksmart.net)")
                                    .referrer("http://www.youtube.com")
                                    .timeout(30000)
                                    .proxy(proxy)
                                    .followRedirects(true)
                                    .execute();
                        } catch (IOException e) {
                            log.error(e.getMessage());
                        }
                        if (response3 != null) {
                            Document europeOdds2 = response3.parse();
                            Elements divList2 = europeOdds2.getElementsByClass("bg-default rounded p-2 p-md-3 mb-2 mb-md-3");
                            Elements trList = null;
                            for (Element element : divList2
                            ) {
                                if ("胜平负指数".equals(element.getElementsByClass("text-center pb-2 font-16 font-weight-bold").text())) {
                                    if (element.getElementsByTag("tbody").size() > 1) {
                                        trList = element.getElementsByTag("tbody").get(1).getElementsByTag("tr");
                                    }
                                }
                            }
                            if (trList != null && trList.size() > 0) {
                                //                最后一个就是初盘
                                Element startHandCap = trList.get(trList.size() - 1);
//                    即时代表还没开赛，实时赔率代表已经开始踢了
                                Elements oldTdList = startHandCap.getElementsByTag("td");
                                if (oldTdList.get(4).text().contains("/")) {
                                    BigDecimal oldWin = new BigDecimal(oldTdList.get(1).text());
                                    BigDecimal oldDraw = new BigDecimal(oldTdList.get(2).text());
                                    BigDecimal oldLose = new BigDecimal(oldTdList.get(3).text());
                                    LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getBankerName, quancheng);
                                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeWinHandicap, oldWin);
                                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeDrawHandicap, oldDraw);
                                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getHomeLoseHandicap, oldLose);
                                    List<EuropeBankerInfoPO> europeBankerInfoPOList = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper);
                                    if (europeBankerInfoPOList == null || europeBankerInfoPOList.size() == 0) {
                                        EuropeBankerInfoPO europeBankerInfoPO = new EuropeBankerInfoPO();
                                        europeBankerInfoPO.setBankerName(quancheng);
                                        europeBankerInfoPO.setHomeWinHandicap(oldWin);
                                        europeBankerInfoPO.setHomeDrawHandicap(oldDraw);
                                        europeBankerInfoPO.setHomeLoseHandicap(oldLose);
//                            添加初盘数据
                                        europeBankerInfoPO.setPlayInfoId(playInfoPO.getId());
                                        europeBankerInfoPO.setStartNowHandicapFlag("0");// 0: 初盘
                                        europeBankerInfoPO.setCreateTime(DateUtil.parse(oldTdList.get(4).text(), "MM/dd HH:mm"));
                                        insertEuropeList.add(europeBankerInfoPO);
                                    }
                                }
//                    判断一下，防止只有一条初盘数据没有即盘，无法做后续处理
                                if (trList.size() > 1) {
                                    for (int j = 0; j < trList.size() - 1; j++) {
                                        //                    胜
                                        Elements tdList = trList.get(j).getElementsByTag("td");
                                        if (tdList.get(4).text().contains("/")) {
                                            BigDecimal newWin = new BigDecimal(tdList.get(1).text());
                                            BigDecimal newDraw = new BigDecimal(tdList.get(2).text());
                                            BigDecimal newLose = new BigDecimal(tdList.get(3).text());
                                            LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
                                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getBankerName, quancheng);
                                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeWinHandicap, newWin);
                                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeDrawHandicap, newDraw);
                                            europeBankerInfoPOLambdaQueryWrapper2.eq(EuropeBankerInfoPO::getHomeLoseHandicap, newLose);
                                            List<EuropeBankerInfoPO> europeBankerInfoPOList2 = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper2);
//                            没有即盘数据则添加，有可能是发生了变化，继续添加即可。
                                            if (europeBankerInfoPOList2 == null || europeBankerInfoPOList2.size() == 0) {
                                                EuropeBankerInfoPO europeBankerInfoPO = new EuropeBankerInfoPO();
                                                europeBankerInfoPO.setBankerName(quancheng);
                                                europeBankerInfoPO.setHomeWinHandicap(newWin);
                                                europeBankerInfoPO.setHomeDrawHandicap(newDraw);
                                                europeBankerInfoPO.setHomeLoseHandicap(newLose);
//                            添加即时数据
                                                europeBankerInfoPO.setPlayInfoId(playInfoPO.getId());
                                                europeBankerInfoPO.setStartNowHandicapFlag("1");// 1: 即盘
//                                    带 / 说明是赛前即盘，不带是比赛中的即盘

                                                europeBankerInfoPO.setCreateTime(DateUtil.parse(tdList.get(4).text(), "MM/dd HH:mm"));
                                                insertEuropeList.add(europeBankerInfoPO);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //        playInfoService.saveBatch(insertPlayList);
            playInfoService.updateBatchById(updatePlayList);
//        asianBankerInfoService.saveBatch(insertAsianList);
            europeBankerInfoService.saveBatch(insertEuropeList);
            log.warn("爬取结束---------------------------------");
        }

    }


    /**
     * 更新预测的结果是否准确
     */
//    @Scheduled(cron = "0 0/30 * * * ?") //每30分钟自动执行一次
    @Transactional
    public void autoUpdatePredictInfo() throws Exception {
        Date nowDate = new Date();
//        看4小时前的比赛，验证预测结果是否红单
        LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
        playInfoPOLambdaQueryWrapper.between(PlayInfoPO::getPlayingTime, DateUtil.beginOfDay(nowDate), DateUtil.offsetHour(nowDate, -4));
//        playInfoPOLambdaQueryWrapper.between(PlayInfoPO::getPlayingTime, DateUtil.beginOfDay(DateUtil.parse("2023-12-04")), DateUtil.endOfDay(DateUtil.parse("2023-12-05")));

        List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
        if (playInfoPOS != null && playInfoPOS.size() > 0) {
            for (PlayInfoPO playInfoPO : playInfoPOS
            ) {
                LambdaQueryWrapper<PredictAccuracyPO> poLambdaQueryWrapper = new LambdaQueryWrapper<>();
                poLambdaQueryWrapper.eq(PredictAccuracyPO::getPlayInfoId, playInfoPO.getId());
                List<PredictAccuracyPO> predictAccuracyPOS = predictAccuracyMapper.selectList(poLambdaQueryWrapper);
                if (predictAccuracyPOS == null || predictAccuracyPOS.size() == 0) {
                    asianBankerInfoService.batchInsertPreResult(playInfoPO);
                }
            }
        }
    }



    /**
     * 临场预测接口 早7点到晚上10点
     */
//    @Scheduled(cron = "0 0/15 7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * ?")
    @Scheduled(cron = "0 0/15 * * * ?")
    @Transactional
    public void autoUpdateAsianPredictInfo3() {
        Date nowDate = new Date();
        LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
        // 设置查询条件
        playInfoPOLambdaQueryWrapper.between(PlayInfoPO::getPlayingTime, DateUtil.offsetMinute(nowDate, -15), DateUtil.offsetHour(nowDate, 8));//7小时内的比赛
//        playInfoPOLambdaQueryWrapper.between(PlayInfoPO::getPlayingTime,DateUtil.parse("2024-09-17 08:30:00"), DateUtil.parse("2024-09-17 12:00:00"));
        playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getPredictResultAsian, "");//为空,没预测过的比赛
//        playInfoPOLambdaQueryWrapper.notIn(PlayInfoPO::getEventName,EnumCommon.list);//太野鸡的直接不做分析，不浪费钱
        playInfoPOLambdaQueryWrapper.ne(PlayInfoPO::getPredictResultAsian, "数据不完整,不建议投资");
        playInfoPOLambdaQueryWrapper.isNotNull(PlayInfoPO::getDetailInfo);//null的详细数据不做预测
//        playInfoPOLambdaQueryWrapper.in(PlayInfoPO::getId,1836073423489785857L,1836073437083525121L);//null的详细数据不做预测

        List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
        List<PlayInfoPO> updatePOList = new ArrayList<>();
        if (playInfoPOS != null && !playInfoPOS.isEmpty()) {
            if(playInfoPOS.size() > 3){//大于3个的时候只取3个
                playInfoPOS = playInfoPOS.subList(0, 3);
            }
            for (PlayInfoPO playInfoPO : playInfoPOS) {
                Long id = playInfoPO.getId();

                LambdaQueryWrapper<AsianBankerInfoPO> asianBankerInfoPOLambdaQueryWrapper3 = new LambdaQueryWrapper<>();
                asianBankerInfoPOLambdaQueryWrapper3.eq(AsianBankerInfoPO::getPlayInfoId, id);
                asianBankerInfoPOLambdaQueryWrapper3.select(AsianBankerInfoPO::getBankerName, AsianBankerInfoPO::getHomeHandicap, AsianBankerInfoPO::getVisitHandicap, AsianBankerInfoPO::getHandicapName,
                        AsianBankerInfoPO::getCreateTime);
                asianBankerInfoPOLambdaQueryWrapper3.orderByDesc(AsianBankerInfoPO::getCreateTime);//必须倒序，下面循环好操作最新数据塞进去
                List<AsianBankerInfoPO> asianBankerInfoPOS = asianBankerInfoMapper.selectList(asianBankerInfoPOLambdaQueryWrapper3);
                if (asianBankerInfoPOS != null && asianBankerInfoPOS.size() > 0) {
                    // 使用流式API过滤
                    Map<String, Long> asianBankerName = asianBankerInfoPOS.stream()
                            .collect(Collectors.groupingBy(AsianBankerInfoPO::getBankerName, Collectors.counting()));
                    //  过滤少于10条的数据
                    asianBankerInfoPOS = asianBankerInfoPOS.stream()
                            .filter(record -> asianBankerName.get(record.getBankerName()) >= 3)
                            .collect(Collectors.toList());
                    for (AsianBankerInfoPO asianBankerInfoPO : asianBankerInfoPOS
                    ) {
//                        升和降的字样去掉，可能会误导ai
                        asianBankerInfoPO.setHandicapName(asianBankerInfoPO.getHandicapName().replaceAll("升", "").replaceAll("降", ""));
                        if ("10BET".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家1");
                        } else if ("12BET (壹�E博)".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家2");
                        } else if ("Bet365".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家3");
                        } else if ("Bwin".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家4");
                        } else if ("Interwetten".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家5");
                        } else if ("Mansion88 (明升)".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家6");
                        } else if ("Pinnacle平博".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家7");
                        } else if ("伟德".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家8");
                        } else if ("利记".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家9");
                        } else if ("威廉希尔".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家10");
                        } else if ("易胜博".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家11");
                        } else if ("澳门".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家12");
                        } else if ("皇冠".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家13");
                        } else if ("立博".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家14");
                        } else if ("金宝博".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家15");
                        } else if ("香港马会".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家16");
                        }
                    }
                    LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getPlayInfoId, id);
                    europeBankerInfoPOLambdaQueryWrapper.select(EuropeBankerInfoPO::getBankerName, EuropeBankerInfoPO::getHomeWinHandicap, EuropeBankerInfoPO::getHomeDrawHandicap, EuropeBankerInfoPO::getHomeLoseHandicap,
                            EuropeBankerInfoPO::getCreateTime);
                    europeBankerInfoPOLambdaQueryWrapper.orderByDesc(EuropeBankerInfoPO::getCreateTime);
                    List<EuropeBankerInfoPO> europeBankerInfoPOList = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper);
                    if (europeBankerInfoPOList != null && europeBankerInfoPOList.size() > 0) {
                        // 使用流式API过滤
                        Map<String, Long> europeBankerName = europeBankerInfoPOList.stream()
                                .collect(Collectors.groupingBy(EuropeBankerInfoPO::getBankerName, Collectors.counting()));
                        //  过滤少于10条的数据
                        europeBankerInfoPOList = europeBankerInfoPOList.stream()
                                .filter(record -> europeBankerName.get(record.getBankerName()) >= 3)
                                .collect(Collectors.toList());
                        LambdaQueryWrapper<BigSmallInfo> bigSmallInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getPlayInfoId, id);
                        bigSmallInfoLambdaQueryWrapper.select(BigSmallInfo::getBankerName, BigSmallInfo::getBigHandicap, BigSmallInfo::getSmallHandicap, BigSmallInfo::getCreateTime, BigSmallInfo::getHandicapName);
                        bigSmallInfoLambdaQueryWrapper.orderByDesc(BigSmallInfo::getCreateTime);
                        List<BigSmallInfo> bigSmallInfos = bigSmallInfoMapper.selectList(bigSmallInfoLambdaQueryWrapper);
                        if (bigSmallInfos != null && bigSmallInfos.size() > 0) {
                            // 使用流式API过滤
                            Map<String, Long> bigBankerName = bigSmallInfos.stream()
                                    .collect(Collectors.groupingBy(BigSmallInfo::getBankerName, Collectors.counting()));
                            //  过滤少于10条的数据
                            bigSmallInfos = bigSmallInfos.stream()
                                    .filter(record -> bigBankerName.get(record.getBankerName()) >= 3)
                                    .collect(Collectors.toList());
                            for (BigSmallInfo bigSmallInfo : bigSmallInfos
                            ) {
                                if ("10BET".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家1");
                                } else if ("12BET (壹�E博)".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家2");
                                } else if ("Bet365".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家3");
                                } else if ("Bwin".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家4");
                                } else if ("Interwetten".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家5");
                                } else if ("Mansion88 (明升)".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家6");
                                } else if ("Pinnacle平博".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家7");
                                } else if ("伟德".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家8");
                                } else if ("利记".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家9");
                                } else if ("威廉希尔".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家10");
                                } else if ("易胜博".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家11");
                                } else if ("澳门".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家12");
                                } else if ("皇冠".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家13");
                                } else if ("立博".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家14");
                                } else if ("金宝博".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家15");
                                } else if ("香港马会".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家16");
                                }
                            }
                            for (EuropeBankerInfoPO europeBankerInfoPO1 : europeBankerInfoPOList
                            ) {
                                if ("10BET".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家1");
                                } else if ("12BET (壹�E博)".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家2");
                                } else if ("Bet365".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家3");
                                } else if ("Bwin".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家4");
                                } else if ("Interwetten".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家5");
                                } else if ("Mansion88 (明升)".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家6");
                                } else if ("Pinnacle平博".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家7");
                                } else if ("伟德".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家8");
                                } else if ("利记".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家9");
                                } else if ("威廉希尔".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家10");
                                } else if ("易胜博".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家11");
                                } else if ("澳门".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家12");
                                } else if ("皇冠".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家13");
                                } else if ("立博".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家14");
                                } else if ("金宝博".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家15");
                                } else if ("香港马会".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家16");
                                }
                            }
                            if(europeBankerInfoPOList.size() == 0 || bigSmallInfos.size() == 0 || asianBankerInfoPOS.size() == 0){
                                continue;//任何list筛选后如果等于0，就直接停了
                            }
                            try {
                                List<Message> messages = new ArrayList<>();
//                                messages.add(AlibabaUtils.createMessage(Role.SYSTEM, "建立一个综合性的足球比赛预测模型，能够根据输入的多种数据，对比赛结果进行预测，并给出相应的投资建议。"));
                                List<AsianBankerInfoVO> asianBankerInfoVOList = new ArrayList<>();
                                for (AsianBankerInfoPO asianBankerInfoPO : asianBankerInfoPOS
                                ) {
                                    AsianBankerInfoVO asianBankerInfoVO = new AsianBankerInfoVO();
                                    BeanUtils.copyProperties(asianBankerInfoPO, asianBankerInfoVO);
                                    asianBankerInfoVO.setCreateTime(DateUtil.format(asianBankerInfoPO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                                    asianBankerInfoVOList.add(asianBankerInfoVO);
                                    if (asianBankerInfoVOList.toString().length() >= 150000) {
                                        break;
                                    }
                                }
                                Collections.reverse(asianBankerInfoVOList);


                                List<EuropeBankerInfoVO> europeBankerInfoVOList = new ArrayList<>();
                                for (EuropeBankerInfoPO europeBankerInfoPO : europeBankerInfoPOList
                                ) {
                                    EuropeBankerInfoVO europeBankerInfoVO = new EuropeBankerInfoVO();
                                    BeanUtils.copyProperties(europeBankerInfoPO, europeBankerInfoVO);
                                    europeBankerInfoVO.setCreateTime(DateUtil.format(europeBankerInfoPO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                                    europeBankerInfoVOList.add(europeBankerInfoVO);
                                    if (europeBankerInfoVOList.toString().length() >= 150000) {
                                        break;
                                    }
                                }
                                Collections.reverse(europeBankerInfoVOList);
                                List<BigSmallInfoVO> bigSmallInfoVOList = new ArrayList<>();
                                for (BigSmallInfo bigSmallInfo : bigSmallInfos
                                ) {
                                    BigSmallInfoVO bigSmallInfoVO = new BigSmallInfoVO();
                                    BeanUtils.copyProperties(bigSmallInfo, bigSmallInfoVO);
                                    bigSmallInfoVO.setCreateTime(DateUtil.format(bigSmallInfo.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                                    bigSmallInfoVOList.add(bigSmallInfoVO);
                                    if (bigSmallInfoVOList.toString().length() >= 150000) {
                                        break;
                                    }
                                }
                                Collections.reverse(bigSmallInfoVOList);

                                String asianStr;
                                asianStr = asianBankerInfoVOList.toString().replaceAll("AsianBankerInfoVO", "").replaceAll("homeHandicap", "主队水位").replaceAll("visitHandicap", "客队水位").replaceAll("bankerName", "庄家名称").replaceAll("handicapName", "盘口");

                                String europeStr;
                                europeStr = europeBankerInfoVOList.toString().replaceAll("EuropeBankerInfoVO", "").replaceAll("homeWinHandicap", "主胜水位").replaceAll("homeLoseHandicap", "客胜水位").replaceAll("homeDrawHandicap", "平局水位").replaceAll("bankerName", "庄家名称");

                                String bigStr;
                                bigStr = bigSmallInfoVOList.toString().replaceAll("BigSmallInfoVO", "").replaceAll("bigHandicap", "大球盘水位").replaceAll("smallHandicap", "小球盘水位").replaceAll("bankerName", "庄家名称").replaceAll("handicapName", "大小球盘口");

//                                系统角色
                                messages.add(AlibabaUtils.createMessage(Role.SYSTEM,
                                        "你是一位经验丰富的足球预测分析师，擅长利用基本数据来预测比赛走势。"));

                                messages.add(AlibabaUtils.createMessage(Role.USER,
                                        "比赛双方：[" + playInfoPO.getHomeName() + "] vs [" + playInfoPO.getVisitName() + "]\n" +
                                                "比赛时间：[" + DateUtil.format(playInfoPO.getPlayingTime(), "yyyy-MM-dd HH:mm:ss") + "]\n" +
                                                "球队基本面信息：[" + playInfoPO.getDetailInfo() + "]\n" +
//                                                "###亚洲盘赔率数据：" + asianStr + "\n" +
//                                                "###欧洲盘赔率数据：" + europeStr + "\n" +
//                                                "###大小球盘赔率数据：" + bigStr + "\n" +
                                                "1.利用基本面信息分析主胜/平局/客胜/可能的比分"));
                                GenerationParam param = AlibabaUtils.createGenerationParam(messages);
                                GenerationResult result = AlibabaUtils.callGenerationWithMessages(param);
                                if (StringUtils.isNotBlank(result.getOutput().getChoices().get(0).getMessage().getContent())) {
//                                    替换掉没用的符号
                                    playInfoPO.setPredictResultAsian(result.getOutput().getChoices().get(0).getMessage().getContent().replaceAll("\\*", "").replaceAll("/", "").replaceAll("#", ""));
                                }
                            } catch (ApiException | NoApiKeyException | InputRequiredException e) {
                                log.error("遇到错误,playInfoId:" + playInfoPO.getId());
                                log.error(e.getMessage());
                                e.printStackTrace();
                            }
                        }


                    }
                }
                updatePOList.add(playInfoPO);
            }
        }
        playInfoService.updateBatchById(updatePOList);
    }

    /**
     * 预测一整晚的 23点的
     */
//    @Scheduled(cron = "0 0 23 * * ?")
//    @Transactional
//    public void autoUpdateAsianPredictInfo4() {
//        Date nowDate = new Date();
//        LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
//        // 设置查询条件
//        playInfoPOLambdaQueryWrapper.between(PlayInfoPO::getPlayingTime, DateUtil.offsetMinute(nowDate, -15), DateUtil.offsetHour(nowDate, 8));//7小时内的比赛
////        playInfoPOLambdaQueryWrapper.between(PlayInfoPO::getPlayingTime,DateUtil.parse("2024-09-11 17:30:00"), DateUtil.parse("2024-09-11 18:00:00"));
//        playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getPredictResultAsian, "");//为空,没预测过的比赛
//        playInfoPOLambdaQueryWrapper.notIn(PlayInfoPO::getEventName,EnumCommon.list);//太野鸡的直接不做分析，不浪费钱
//        playInfoPOLambdaQueryWrapper.ne(PlayInfoPO::getPredictResultAsian, "数据不完整,不建议投资");
//        playInfoPOLambdaQueryWrapper.isNotNull(PlayInfoPO::getDetailInfo);//null的详细数据不做预测
////        playInfoPOLambdaQueryWrapper.in(PlayInfoPO::getId,1833173895468060673L,1833173901281366018L);//null的详细数据不做预测
//
//        List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
//        List<PlayInfoPO> updatePOList = new ArrayList<>();
//        if (playInfoPOS != null && !playInfoPOS.isEmpty()) {
//            for (PlayInfoPO playInfoPO : playInfoPOS) {
//                Long id = playInfoPO.getId();
//
//                LambdaQueryWrapper<AsianBankerInfoPO> asianBankerInfoPOLambdaQueryWrapper3 = new LambdaQueryWrapper<>();
//                asianBankerInfoPOLambdaQueryWrapper3.eq(AsianBankerInfoPO::getPlayInfoId, id);
//                asianBankerInfoPOLambdaQueryWrapper3.select(AsianBankerInfoPO::getBankerName, AsianBankerInfoPO::getHomeHandicap, AsianBankerInfoPO::getVisitHandicap, AsianBankerInfoPO::getHandicapName,
//                        AsianBankerInfoPO::getCreateTime);
//                asianBankerInfoPOLambdaQueryWrapper3.orderByDesc(AsianBankerInfoPO::getCreateTime);//必须倒序，下面循环好操作最新数据塞进去
//                List<AsianBankerInfoPO> asianBankerInfoPOS = asianBankerInfoMapper.selectList(asianBankerInfoPOLambdaQueryWrapper3);
//                if (asianBankerInfoPOS != null && asianBankerInfoPOS.size() > 0) {
//                    // 使用流式API过滤
//                    Map<String, Long> asianBankerName = asianBankerInfoPOS.stream()
//                            .collect(Collectors.groupingBy(AsianBankerInfoPO::getBankerName, Collectors.counting()));
//                    //  过滤少于10条的数据
//                    asianBankerInfoPOS = asianBankerInfoPOS.stream()
//                            .filter(record -> asianBankerName.get(record.getBankerName()) >= 10)
//                            .collect(Collectors.toList());
//                    for (AsianBankerInfoPO asianBankerInfoPO : asianBankerInfoPOS
//                    ) {
////                        升和降的字样去掉，可能会误导ai
//                        asianBankerInfoPO.setHandicapName(asianBankerInfoPO.getHandicapName().replaceAll("升", "").replaceAll("降", ""));
//                        if ("10BET".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家1");
//                        } else if ("12BET (壹�E博)".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家2");
//                        } else if ("Bet365".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家3");
//                        } else if ("Bwin".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家4");
//                        } else if ("Interwetten".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家5");
//                        } else if ("Mansion88 (明升)".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家6");
//                        } else if ("Pinnacle平博".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家7");
//                        } else if ("伟德".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家8");
//                        } else if ("利记".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家9");
//                        } else if ("威廉希尔".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家10");
//                        } else if ("易胜博".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家11");
//                        } else if ("澳门".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家12");
//                        } else if ("皇冠".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家13");
//                        } else if ("立博".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家14");
//                        } else if ("金宝博".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家15");
//                        } else if ("香港马会".equals(asianBankerInfoPO.getBankerName())) {
//                            asianBankerInfoPO.setBankerName("庄家16");
//                        }
//                    }
//                    LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
//                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getPlayInfoId, id);
//                    europeBankerInfoPOLambdaQueryWrapper.select(EuropeBankerInfoPO::getBankerName, EuropeBankerInfoPO::getHomeWinHandicap, EuropeBankerInfoPO::getHomeDrawHandicap, EuropeBankerInfoPO::getHomeLoseHandicap,
//                            EuropeBankerInfoPO::getCreateTime);
//                    europeBankerInfoPOLambdaQueryWrapper.orderByDesc(EuropeBankerInfoPO::getCreateTime);
//                    List<EuropeBankerInfoPO> europeBankerInfoPOList = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper);
//                    if (europeBankerInfoPOList != null && europeBankerInfoPOList.size() > 0) {
//                        // 使用流式API过滤
//                        Map<String, Long> europeBankerName = europeBankerInfoPOList.stream()
//                                .collect(Collectors.groupingBy(EuropeBankerInfoPO::getBankerName, Collectors.counting()));
//                        //  过滤少于10条的数据
//                        europeBankerInfoPOList = europeBankerInfoPOList.stream()
//                                .filter(record -> europeBankerName.get(record.getBankerName()) >= 10)
//                                .collect(Collectors.toList());
//                        LambdaQueryWrapper<BigSmallInfo> bigSmallInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
//                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getPlayInfoId, id);
//                        bigSmallInfoLambdaQueryWrapper.select(BigSmallInfo::getBankerName, BigSmallInfo::getBigHandicap, BigSmallInfo::getSmallHandicap, BigSmallInfo::getCreateTime, BigSmallInfo::getHandicapName);
//                        bigSmallInfoLambdaQueryWrapper.orderByDesc(BigSmallInfo::getCreateTime);
//                        List<BigSmallInfo> bigSmallInfos = bigSmallInfoMapper.selectList(bigSmallInfoLambdaQueryWrapper);
//                        if (bigSmallInfos != null && bigSmallInfos.size() > 0) {
//                            // 使用流式API过滤
//                            Map<String, Long> bigBankerName = bigSmallInfos.stream()
//                                    .collect(Collectors.groupingBy(BigSmallInfo::getBankerName, Collectors.counting()));
//                            //  过滤少于10条的数据
//                            bigSmallInfos = bigSmallInfos.stream()
//                                    .filter(record -> bigBankerName.get(record.getBankerName()) >= 10)
//                                    .collect(Collectors.toList());
//                            for (BigSmallInfo bigSmallInfo : bigSmallInfos
//                            ) {
//                                if ("10BET".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家1");
//                                } else if ("12BET (壹�E博)".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家2");
//                                } else if ("Bet365".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家3");
//                                } else if ("Bwin".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家4");
//                                } else if ("Interwetten".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家5");
//                                } else if ("Mansion88 (明升)".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家6");
//                                } else if ("Pinnacle平博".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家7");
//                                } else if ("伟德".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家8");
//                                } else if ("利记".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家9");
//                                } else if ("威廉希尔".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家10");
//                                } else if ("易胜博".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家11");
//                                } else if ("澳门".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家12");
//                                } else if ("皇冠".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家13");
//                                } else if ("立博".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家14");
//                                } else if ("金宝博".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家15");
//                                } else if ("香港马会".equals(bigSmallInfo.getBankerName())) {
//                                    bigSmallInfo.setBankerName("庄家16");
//                                }
//                            }
//                            for (EuropeBankerInfoPO europeBankerInfoPO1 : europeBankerInfoPOList
//                            ) {
//                                if ("10BET".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家1");
//                                } else if ("12BET (壹�E博)".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家2");
//                                } else if ("Bet365".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家3");
//                                } else if ("Bwin".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家4");
//                                } else if ("Interwetten".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家5");
//                                } else if ("Mansion88 (明升)".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家6");
//                                } else if ("Pinnacle平博".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家7");
//                                } else if ("伟德".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家8");
//                                } else if ("利记".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家9");
//                                } else if ("威廉希尔".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家10");
//                                } else if ("易胜博".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家11");
//                                } else if ("澳门".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家12");
//                                } else if ("皇冠".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家13");
//                                } else if ("立博".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家14");
//                                } else if ("金宝博".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家15");
//                                } else if ("香港马会".equals(europeBankerInfoPO1.getBankerName())) {
//                                    europeBankerInfoPO1.setBankerName("庄家16");
//                                }
//                            }
//                            if(europeBankerInfoPOList.size() == 0 || bigSmallInfos.size() == 0 || asianBankerInfoPOS.size() == 0){
//                                return;//任何list筛选后如果等于0，就直接停了
//                            }
//                            try {
//                                List<Message> messages = new ArrayList<>();
////                                messages.add(AlibabaUtils.createMessage(Role.SYSTEM, "建立一个综合性的足球比赛预测模型，能够根据输入的多种数据，对比赛结果进行预测，并给出相应的投资建议。"));
//                                List<AsianBankerInfoVO> asianBankerInfoVOList = new ArrayList<>();
//                                for (AsianBankerInfoPO asianBankerInfoPO : asianBankerInfoPOS
//                                ) {
//                                    AsianBankerInfoVO asianBankerInfoVO = new AsianBankerInfoVO();
//                                    BeanUtils.copyProperties(asianBankerInfoPO, asianBankerInfoVO);
//                                    asianBankerInfoVO.setCreateTime(DateUtil.format(asianBankerInfoPO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
//                                    asianBankerInfoVOList.add(asianBankerInfoVO);
//                                    if (asianBankerInfoVOList.toString().length() >= 100000) {
//                                        break;
//                                    }
//                                }
//                                Collections.reverse(asianBankerInfoVOList);
//
//
//                                List<EuropeBankerInfoVO> europeBankerInfoVOList = new ArrayList<>();
//                                for (EuropeBankerInfoPO europeBankerInfoPO : europeBankerInfoPOList
//                                ) {
//                                    EuropeBankerInfoVO europeBankerInfoVO = new EuropeBankerInfoVO();
//                                    BeanUtils.copyProperties(europeBankerInfoPO, europeBankerInfoVO);
//                                    europeBankerInfoVO.setCreateTime(DateUtil.format(europeBankerInfoPO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
//                                    europeBankerInfoVOList.add(europeBankerInfoVO);
//                                    if (europeBankerInfoVOList.toString().length() >= 100000) {
//                                        break;
//                                    }
//                                }
//                                Collections.reverse(europeBankerInfoVOList);
//                                List<BigSmallInfoVO> bigSmallInfoVOList = new ArrayList<>();
//                                for (BigSmallInfo bigSmallInfo : bigSmallInfos
//                                ) {
//                                    BigSmallInfoVO bigSmallInfoVO = new BigSmallInfoVO();
//                                    BeanUtils.copyProperties(bigSmallInfo, bigSmallInfoVO);
//                                    bigSmallInfoVO.setCreateTime(DateUtil.format(bigSmallInfo.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
//                                    bigSmallInfoVOList.add(bigSmallInfoVO);
//                                    if (bigSmallInfoVOList.toString().length() >= 100000) {
//                                        break;
//                                    }
//                                }
//                                Collections.reverse(bigSmallInfoVOList);
//
//                                String asianStr;
//                                asianStr = asianBankerInfoVOList.toString().replaceAll("AsianBankerInfoVO", "").replaceAll("homeHandicap", "主队水位").replaceAll("visitHandicap", "客队水位").replaceAll("bankerName", "庄家名称").replaceAll("handicapName", "盘口");
//
//                                String europeStr;
//                                europeStr = europeBankerInfoVOList.toString().replaceAll("EuropeBankerInfoVO", "").replaceAll("homeWinHandicap", "主胜水位").replaceAll("homeLoseHandicap", "客胜水位").replaceAll("homeDrawHandicap", "平局水位").replaceAll("bankerName", "庄家名称");
//
//                                String bigStr;
//                                bigStr = bigSmallInfoVOList.toString().replaceAll("BigSmallInfoVO", "").replaceAll("bigHandicap", "大球盘水位").replaceAll("smallHandicap", "小球盘水位").replaceAll("bankerName", "庄家名称").replaceAll("handicapName", "大小球盘口");
//
//
//                                messages.add(AlibabaUtils.createMessage(Role.USER,
//                                        "基本信息\n" +
//                                                "比赛双方：[" + playInfoPO.getHomeName() + "] vs [" + playInfoPO.getVisitName() + "]\n" +
//                                                "比赛时间：[" + DateUtil.format(playInfoPO.getPlayingTime(),"yyyy-MM-dd HH:mm:ss") + "]\n" +
//                                                "当前时间：[" + DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss") + "]\n" +
//                                                "基本面信息：[" + playInfoPO.getDetailInfo() + "]\n" +
//                                                "赔率分析\n" +
//                                                "###亚洲盘口赔率数据：" + asianStr + "\n" +
//                                                "###欧洲盘口赔率数据：" + europeStr + "\n" +
//                                                "###大小球盘口赔率数据：" + bigStr + "\n" +
//                                                "###1.利用赔率数据识别公司态度和市场情绪 \n 2.利用双方近期战绩与历史交锋记录识别两只球队该场比赛的预期表现 \n 3.结合预期表现与公司态度和市场情绪进行综合分析。\n" +
//                                                "对于平手盘(输出主胜、平局、客胜的百分比概率):\n" +
//                                                "评估: 基于球队的近况和历史对战数据来估算胜、平、负的概率。\n" +
//                                                "推荐: 如果主队的胜或平概率较高，推荐主队赢亚盘；反之，推荐客队赢亚盘。\n" +
//                                                "对于平手半球、半球或半球一球盘口(输出主胜、平局、客胜的百分比概率):\n" +
//                                                "评估: 同样使用球队的近况和历史数据来估算胜、平、负的概率。\n" +
//                                                "推荐: 根据概率推荐某一方的亚洲盘口。\n" +
//                                                "当盘口深度达到或超过一球时:\n" +
//                                                "评估: 评估强队净胜足够球数的可能性。\n" +
//                                                "推荐: 如果强队有较大可能覆盖盘口，建议投注强队；否则，建议投注弱队的受让盘" +
//                                                "使用泊松分布来预测这场比赛的比分"));
//                                GenerationParam param = AlibabaUtils.createGenerationParam(messages);
//                                GenerationResult result = AlibabaUtils.callGenerationWithMessages(param);
//                                if (StringUtils.isNotBlank(result.getOutput().getChoices().get(0).getMessage().getContent())) {
////                                    替换掉没用的符号
//                                    playInfoPO.setPredictResultAsian(result.getOutput().getChoices().get(0).getMessage().getContent().replaceAll("\\*", "").replaceAll("/", "").replaceAll("#", ""));
//                                }
//                            } catch (ApiException | NoApiKeyException | InputRequiredException e) {
//                                log.error("遇到错误,playInfoId:" + playInfoPO.getId());
//                                log.error(e.getMessage());
//                                e.printStackTrace();
//                            }
//                        }
//
//
//                    }
//                }
//                updatePOList.add(playInfoPO);
//            }
//        }
//        playInfoService.updateBatchById(updatePOList);
//    }

    /**
     * 体彩预测接口 预测9小时后的  每天早上8点和晚上8/9点 预测主流联赛供雷速号使用
     */
//    @Scheduled(cron = "0 0/10 20,21 * * ? ")
    @Transactional
    public void sportsLotteryPrediction() {
        Date nowDate = new Date();
        LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
        // 设置查询条件
        playInfoPOLambdaQueryWrapper.between(PlayInfoPO::getPlayingTime, DateUtil.offsetMinute(nowDate, -15), DateUtil.offsetHour(nowDate, 9));//9小时内的比赛
        playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getPredictResultAsian, "");//为空,没预测过的比赛
        playInfoPOLambdaQueryWrapper.eq(PlayInfoPO::getPredictResultEurope, "");//为空,没预测过的比赛
        playInfoPOLambdaQueryWrapper.in(PlayInfoPO::getEventName,EnumCommon.list);//指定的比赛
        playInfoPOLambdaQueryWrapper.ne(PlayInfoPO::getPredictResultAsian, "数据不完整,不建议投资");
        playInfoPOLambdaQueryWrapper.isNotNull(PlayInfoPO::getDetailInfo);//null的详细数据不做预测
        List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
        List<PlayInfoPO> updatePOList = new ArrayList<>();
        if (playInfoPOS != null && !playInfoPOS.isEmpty()) {
            if(playInfoPOS.size() >= 5){//每次不要分析太多
                playInfoPOS = playInfoPOS.subList(0, 5);
            }
            for (PlayInfoPO playInfoPO : playInfoPOS) {
                Long id = playInfoPO.getId();

                LambdaQueryWrapper<AsianBankerInfoPO> asianBankerInfoPOLambdaQueryWrapper3 = new LambdaQueryWrapper<>();
                asianBankerInfoPOLambdaQueryWrapper3.eq(AsianBankerInfoPO::getPlayInfoId, id);
                asianBankerInfoPOLambdaQueryWrapper3.select(AsianBankerInfoPO::getBankerName, AsianBankerInfoPO::getHomeHandicap, AsianBankerInfoPO::getVisitHandicap, AsianBankerInfoPO::getHandicapName,
                        AsianBankerInfoPO::getCreateTime);
                asianBankerInfoPOLambdaQueryWrapper3.orderByDesc(AsianBankerInfoPO::getCreateTime);//必须倒序，下面循环好操作最新数据塞进去
                List<AsianBankerInfoPO> asianBankerInfoPOS = asianBankerInfoMapper.selectList(asianBankerInfoPOLambdaQueryWrapper3);
                if (asianBankerInfoPOS != null && asianBankerInfoPOS.size() > 0) {
                    for (AsianBankerInfoPO asianBankerInfoPO : asianBankerInfoPOS
                    ) {
//                        升和降的字样去掉，可能会误导ai
                        asianBankerInfoPO.setHandicapName(asianBankerInfoPO.getHandicapName().replaceAll("升", "").replaceAll("降", ""));
                        if ("10BET".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家1");
                        } else if ("12BET (壹�E博)".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家2");
                        } else if ("Bet365".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家3");
                        } else if ("Bwin".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家4");
                        } else if ("Interwetten".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家5");
                        } else if ("Mansion88 (明升)".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家6");
                        } else if ("Pinnacle平博".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家7");
                        } else if ("伟德".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家8");
                        } else if ("利记".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家9");
                        } else if ("威廉希尔".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家10");
                        } else if ("易胜博".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家11");
                        } else if ("澳门".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家12");
                        } else if ("皇冠".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家13");
                        } else if ("立博".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家14");
                        } else if ("金宝博".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家15");
                        } else if ("香港马会".equals(asianBankerInfoPO.getBankerName())) {
                            asianBankerInfoPO.setBankerName("庄家16");
                        }
                    }
                    LambdaQueryWrapper<EuropeBankerInfoPO> europeBankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                    europeBankerInfoPOLambdaQueryWrapper.eq(EuropeBankerInfoPO::getPlayInfoId, id);
                    europeBankerInfoPOLambdaQueryWrapper.select(EuropeBankerInfoPO::getBankerName, EuropeBankerInfoPO::getHomeWinHandicap, EuropeBankerInfoPO::getHomeDrawHandicap, EuropeBankerInfoPO::getHomeLoseHandicap,
                            EuropeBankerInfoPO::getCreateTime);
                    europeBankerInfoPOLambdaQueryWrapper.orderByDesc(EuropeBankerInfoPO::getCreateTime);
                    List<EuropeBankerInfoPO> europeBankerInfoPOList = europeBankerInfoMapper.selectList(europeBankerInfoPOLambdaQueryWrapper);
                    if (europeBankerInfoPOList != null && europeBankerInfoPOList.size() > 0) {
                        LambdaQueryWrapper<BigSmallInfo> bigSmallInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
                        bigSmallInfoLambdaQueryWrapper.eq(BigSmallInfo::getPlayInfoId, id);
                        bigSmallInfoLambdaQueryWrapper.select(BigSmallInfo::getBankerName, BigSmallInfo::getBigHandicap, BigSmallInfo::getSmallHandicap, BigSmallInfo::getCreateTime, BigSmallInfo::getHandicapName);
                        bigSmallInfoLambdaQueryWrapper.orderByDesc(BigSmallInfo::getCreateTime);
                        List<BigSmallInfo> bigSmallInfos = bigSmallInfoMapper.selectList(bigSmallInfoLambdaQueryWrapper);
                        if (bigSmallInfos != null && bigSmallInfos.size() > 0) {
                            for (BigSmallInfo bigSmallInfo : bigSmallInfos
                            ) {
                                if ("10BET".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家1");
                                } else if ("12BET (壹�E博)".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家2");
                                } else if ("Bet365".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家3");
                                } else if ("Bwin".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家4");
                                } else if ("Interwetten".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家5");
                                } else if ("Mansion88 (明升)".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家6");
                                } else if ("Pinnacle平博".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家7");
                                } else if ("伟德".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家8");
                                } else if ("利记".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家9");
                                } else if ("威廉希尔".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家10");
                                } else if ("易胜博".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家11");
                                } else if ("澳门".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家12");
                                } else if ("皇冠".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家13");
                                } else if ("立博".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家14");
                                } else if ("金宝博".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家15");
                                } else if ("香港马会".equals(bigSmallInfo.getBankerName())) {
                                    bigSmallInfo.setBankerName("庄家16");
                                }
                            }
                            for (EuropeBankerInfoPO europeBankerInfoPO1 : europeBankerInfoPOList
                            ) {
                                if ("10BET".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家1");
                                } else if ("12BET (壹�E博)".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家2");
                                } else if ("Bet365".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家3");
                                } else if ("Bwin".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家4");
                                } else if ("Interwetten".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家5");
                                } else if ("Mansion88 (明升)".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家6");
                                } else if ("Pinnacle平博".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家7");
                                } else if ("伟德".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家8");
                                } else if ("利记".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家9");
                                } else if ("威廉希尔".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家10");
                                } else if ("易胜博".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家11");
                                } else if ("澳门".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家12");
                                } else if ("皇冠".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家13");
                                } else if ("立博".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家14");
                                } else if ("金宝博".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家15");
                                } else if ("香港马会".equals(europeBankerInfoPO1.getBankerName())) {
                                    europeBankerInfoPO1.setBankerName("庄家16");
                                }
                            }
                            try {
                                List<Message> messages = new ArrayList<>();
//                                messages.add(AlibabaUtils.createMessage(Role.SYSTEM, "建立一个综合性的足球比赛预测模型，能够根据输入的多种数据，对比赛结果进行预测，并给出相应的投资建议。"));
                                List<AsianBankerInfoVO> asianBankerInfoVOList = new ArrayList<>();
                                for (AsianBankerInfoPO asianBankerInfoPO : asianBankerInfoPOS
                                ) {
                                    AsianBankerInfoVO asianBankerInfoVO = new AsianBankerInfoVO();
                                    BeanUtils.copyProperties(asianBankerInfoPO, asianBankerInfoVO);
                                    asianBankerInfoVO.setCreateTime(DateUtil.format(asianBankerInfoPO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                                    asianBankerInfoVOList.add(asianBankerInfoVO);
                                    if (asianBankerInfoVOList.toString().length() >= 100000) {
                                        break;
                                    }
                                }
                                Collections.reverse(asianBankerInfoVOList);


                                List<EuropeBankerInfoVO> europeBankerInfoVOList = new ArrayList<>();
                                for (EuropeBankerInfoPO europeBankerInfoPO : europeBankerInfoPOList
                                ) {
                                    EuropeBankerInfoVO europeBankerInfoVO = new EuropeBankerInfoVO();
                                    BeanUtils.copyProperties(europeBankerInfoPO, europeBankerInfoVO);
                                    europeBankerInfoVO.setCreateTime(DateUtil.format(europeBankerInfoPO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                                    europeBankerInfoVOList.add(europeBankerInfoVO);
                                    if (europeBankerInfoVOList.toString().length() >= 100000) {
                                        break;
                                    }
                                }
                                Collections.reverse(europeBankerInfoVOList);
                                List<BigSmallInfoVO> bigSmallInfoVOList = new ArrayList<>();
                                for (BigSmallInfo bigSmallInfo : bigSmallInfos
                                ) {
                                    BigSmallInfoVO bigSmallInfoVO = new BigSmallInfoVO();
                                    BeanUtils.copyProperties(bigSmallInfo, bigSmallInfoVO);
                                    bigSmallInfoVO.setCreateTime(DateUtil.format(bigSmallInfo.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                                    bigSmallInfoVOList.add(bigSmallInfoVO);
                                    if (bigSmallInfoVOList.toString().length() >= 100000) {
                                        break;
                                    }
                                }
                                Collections.reverse(bigSmallInfoVOList);

                                String asianStr;
                                asianStr = asianBankerInfoVOList.toString().replaceAll("AsianBankerInfoVO", "").replaceAll("homeHandicap", "主队水位").replaceAll("visitHandicap", "客队水位").replaceAll("bankerName", "庄家名称").replaceAll("handicapName", "盘口");

                                String europeStr;
                                europeStr = europeBankerInfoVOList.toString().replaceAll("EuropeBankerInfoVO", "").replaceAll("homeWinHandicap", "主胜水位").replaceAll("homeLoseHandicap", "客胜水位").replaceAll("homeDrawHandicap", "平局水位").replaceAll("bankerName", "庄家名称");

                                String bigStr;
                                bigStr = bigSmallInfoVOList.toString().replaceAll("BigSmallInfoVO", "").replaceAll("bigHandicap", "大球盘水位").replaceAll("smallHandicap", "小球盘水位").replaceAll("bankerName", "庄家名称").replaceAll("handicapName", "大小球盘口");


                                messages.add(AlibabaUtils.createMessage(Role.USER,
                                        "基本信息\n" +
                                                "比赛双方：[" + playInfoPO.getHomeName() + "] vs [" + playInfoPO.getVisitName() + "]\n" +
                                                "比赛时间：[" + DateUtil.format(playInfoPO.getPlayingTime(),"yyyy-MM-dd HH:mm:ss") + "]\n" +
                                                "当前时间：[" + DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss") + "]\n" +
                                                "赔率分析\n" +
                                                "###亚洲盘口赔率数据：" + asianStr + "\n" +
                                                "###欧洲盘口赔率数据：" + europeStr + "\n" +
                                                "###大小球盘口赔率数据：" + bigStr + "\n" +
                                                "* 主要任务(输出内容简洁明了): *\n" +
                                                "### 初盘数据合理性评估概要(每个庄家的第一条数据即为初盘数据)：\n" +
                                                "1. 初盘设置需要基于队伍的实力、历史对战、心理状态等基本面信息。如果这些信息显示两队势均力敌但初盘却倾向于某一方，则可能存在不合理之处。\n" +
                                                "2. 初盘的合理性还可通过比较不同庄家间的评分和设置来判断。若多数庄家给出相似的赔率但有少数庄家明显偏离，则这些偏离的赔率可能不合理。\n" +
                                                "\n"+
                                                "### 对已有的欧洲盘赔率变化进行解释：\n" +
                                                "1. 赔率的上升通常表明庄家降低对应结果的预期概率，可能是由于市场对该结果的支持减少。\n" +
                                                "2. 赔率的下降则意味着增加对应结果的预期概率，通常与市场投资增多或内部消息影响有关。\n" +
                                                "3. 赔率的调整也可能是为了平衡所有可能结果上的投资，尽量降低庄家自身的风险。\n" +
                                                "\n" +
                                                "### 对已有的亚洲盘赔率变化进行解释：\n" +
                                                "1. 盘口的升降表示庄家对比赛有新的评估和预测。\n" +
                                                "2. 主队赔率的上升或下降直接反映了对主队胜利可能性的重新评估。\n" +
                                                "3. 客队的赔率变动同样反映了市场对客队表现的预期改变。\n" +
                                                "\n" +
                                                "### 对已有的大小球赔率变化进行解释：\n" +
                                                "1. 升盘通常意味着预期总进球数会增多，而降盘则预期减少。\n" +
                                                "2. 小球水位（赔率）的升降反映了庄家对较少总进球的预期变化。\n" +
                                                "3. 大球水位（赔率）的调整则反映了对较多总进球的预期。 \n"+
                                                "\n" +
                                                "### 利用赔率数据和基本面信息计算真实概率：\n" +
                                                "1. 结合基本面信息（如球队历史表现、球员伤病情况、主场优势等）与当前赔率数据，评估每种结果发生的实际概率。\n" +
                                                "2. 使用逆向思维，对比庄家提供的赔率与自己评估的真实概率，识别市场中的价值投资机会。\n" +
                                                "3. 如果某项投资的实际概率大于庄家提供的隐含概率，则认为该投资具有价值。\n" +
                                                "\n" +
                                                "### 确定投资是否具有正的期望值：\n" +
                                                "1. 计算每种结果的期望值，公式为：(获胜概率 * 赔率) - (失败概率 * 投资金额)。\n" +
                                                "2. 如果期望值为正，则该投资具有正的期望值，值得考虑；如果为负，则应避免此类投资。\n" +
                                                "\n" +
                                                "### 投资比例推荐：\n" +
                                                "投资比例建议为总资本的百分比形式。例如：“建议投入总资本的2%。”\n" +
                                                "\n" +
                                                "### 鼓励质疑常规：\n" +
                                                "仔细分析某种逆向投资是否具有正的期望值，即使这可能与大多数人的观点相反。"));
                                GenerationParam param = AlibabaUtils.createGenerationParam(messages);
                                GenerationResult result = AlibabaUtils.callGenerationWithMessages(param);
                                if (StringUtils.isNotBlank(result.getOutput().getChoices().get(0).getMessage().getContent())) {
//                                    替换掉没用的符号
                                    playInfoPO.setPredictResultEurope(result.getOutput().getChoices().get(0).getMessage().getContent().replaceAll("\\*", "").replaceAll("/", "").replaceAll("#", ""));
                                }
                            } catch (ApiException | NoApiKeyException | InputRequiredException e) {
                                log.error("遇到错误,playInfoId:" + playInfoPO.getId());
                                log.error(e.getMessage());
                                e.printStackTrace();
                            }
                        }


                    }
                }
                updatePOList.add(playInfoPO);
            }
        }
        playInfoService.updateBatchById(updatePOList);
    }


    /**
     * 自动计算胜利的赔率
     */
//    @Scheduled(cron = "0 0/1 * * * ?") //每2分钟自动执行一次
    @Transactional
    public void autoMaticallyodds() throws Exception {
        LambdaQueryWrapper<PlayInfoPO> playInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
        playInfoPOLambdaQueryWrapper.between(PlayInfoPO::getPlayingTime, DateUtil.beginOfDay(DateUtil.parse("2024-07-15")), DateUtil.endOfDay(DateUtil.parse("2024-07-15")));
        List<PlayInfoPO> playInfoPOS = playInfoMapper.selectList(playInfoPOLambdaQueryWrapper);
        if (playInfoPOS != null && playInfoPOS.size() > 0) {

            int sumCount = 0;
            int winCount = 0;
            int notCount = 0;
            for (PlayInfoPO playInfoPO : playInfoPOS
            ) {
//                BigDecimal sumBig = new BigDecimal("0.00");
//                BigDecimal sumSmall = new BigDecimal("0.00");
//                BigDecimal de = new BigDecimal("0.80");

                LambdaQueryWrapper<AsianBankerInfoPO> asianBankerInfoPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
                asianBankerInfoPOLambdaQueryWrapper.eq(AsianBankerInfoPO::getPlayInfoId, playInfoPO.getId());
                asianBankerInfoPOLambdaQueryWrapper.between(AsianBankerInfoPO::getCreateTime, DateUtil.offsetMinute(playInfoPO.getPlayingTime(), -5), DateUtil.offsetMinute(playInfoPO.getPlayingTime(), 10));
                asianBankerInfoPOLambdaQueryWrapper.orderByDesc(AsianBankerInfoPO::getCreateTime);
                List<AsianBankerInfoPO> asianBankerInfoPOS = asianBankerInfoMapper.selectList(asianBankerInfoPOLambdaQueryWrapper);
                if (asianBankerInfoPOS != null && asianBankerInfoPOS.size() > 0) {
                    AsianBankerInfoPO asianBankerInfoPO = asianBankerInfoPOS.get(0);
                    String handicapName = asianBankerInfoPO.getHandicapName();
                    handicapName = handicapName.replaceAll("升", "").replaceAll("降", "").replaceAll(" ", "");
                    String predictResultAsian = playInfoPO.getPredictResultAsian();
//                    if (predictResultAsian.contains()"亚盘:看好主队亚盘".equals(predictResultAsian)) {
                    if (predictResultAsian.contains("看好主队亚盘")) {
                        sumCount++;
                        if (handicapName.contains("/")) {
//                            包含/说明是+0/0.5这种盘
                            String[] asianSplit = handicapName.split("/");
                            String abc = EnumCommon.asianMap.get(asianSplit[0]) + "/" + EnumCommon.asianMap.get(asianSplit[1]);
//                                        为什么这么写，因为受球的时候，/后面的字不写受，所以容易误判断为减，其实按前面的走，就是+球
//                                                区分为主队减球还是加球，客队减球还是加球
                            if ("-".equals(abc.substring(0, 1))) {
//                                            减球并且是减0.25及以上必须赢一个才算红单,还要看具体盘口
                                if (playInfoPO.getHomeScore() > playInfoPO.getVisitScore()) {
//                                                -0/0.5
                                    if ("平手".equals(asianSplit[0]) && "半球".equals(asianSplit[1])) {
                                        winCount++;

                                    } else if ("半球".equals(asianSplit[0]) && "一球".equals(asianSplit[1])) {
                                        winCount++;
                                    } else if ("一球".equals(asianSplit[0]) && "球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 2) {
                                            winCount++;

                                        } else {
                                        }
                                    } else if ("球半".equals(asianSplit[0]) && "两球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 2) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("两球".equals(asianSplit[0]) && "两球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 3) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("两球半".equals(asianSplit[0]) && "三球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 3) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("三球".equals(asianSplit[0]) && "三球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 4) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("三球半".equals(asianSplit[0]) && "四球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 4) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("四球".equals(asianSplit[0]) && "四球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 5) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("四球半".equals(asianSplit[0]) && "五球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 5) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("五球".equals(asianSplit[0]) && "五球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 6) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("五球半".equals(asianSplit[0]) && "六球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 6) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    }
                                } else {

                                }
                            } else {
//                                            加球
                                if (playInfoPO.getHomeScore() < playInfoPO.getVisitScore()) {
//                                                +0/0.5
                                    if ("受平手".equals(asianSplit[0]) && "半球".equals(asianSplit[1])) {

                                    } else if ("受半球".equals(asianSplit[0]) && "一球".equals(asianSplit[1])) {

                                    } else if ("受一球".equals(asianSplit[0]) && "球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 2) {

                                        } else {
                                            winCount++;

                                        }
                                    } else if ("受球半".equals(asianSplit[0]) && "两球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 2) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受两球".equals(asianSplit[0]) && "两球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 3) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受两球半".equals(asianSplit[0]) && "三球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 3) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受三球".equals(asianSplit[0]) && "三球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 4) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受三球半".equals(asianSplit[0]) && "四球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 4) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受四球".equals(asianSplit[0]) && "四球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 5) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受四球半".equals(asianSplit[0]) && "五球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 5) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受五球".equals(asianSplit[0]) && "五球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 6) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受五球半".equals(asianSplit[0]) && "六球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 6) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    }
                                } else {
                                    winCount++;

                                }
                            }
                        } else {
//                                        不包含"/"盘,单独的亚盘
                            String abc = EnumCommon.asianMap.get(handicapName);
//                            if(abc == null || "".equals(abc)){
//                                System.out.println(abc);
//                            }
                            if (abc.contains("-")) {
                                if (playInfoPO.getHomeScore() >= playInfoPO.getVisitScore()) {
//                                                -0
                                    if ("平手".equals(handicapName)) {
                                        winCount++;

                                    } else if ("半球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() > playInfoPO.getVisitScore()) {
                                            winCount++;

                                        } else {

                                        }
                                    } else if ("一球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 1) {
                                            winCount++;

                                        } else {

                                        }
                                    } else if ("球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 2) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("两球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 2) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("两球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 3) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("三球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 3) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("三球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 4) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("四球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 4) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("四球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 5) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("五球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 5) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("五球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 6) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    }
                                } else {

                                }
                            } else {
                                if (playInfoPO.getHomeScore() < playInfoPO.getVisitScore()) {
                                    if ("受一球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 2) {

                                        } else {
                                            winCount++;

                                        }
                                    } else if ("受球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 2) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受两球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 3) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受两球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 3) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受三球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 4) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受三球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 4) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受四球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 5) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受四球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 5) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受五球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 6) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受五球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 6) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    }
                                } else {
                                    winCount++;

                                }
                            }
                        }
//                    } else if ("亚盘:看好客队亚盘".equals(predictResultAsian)) {
                    } else if (predictResultAsian.contains("看好客队亚盘")) {
                        sumCount++;
                        if (handicapName.contains("受")) {
                            handicapName = handicapName.replaceAll("受", "");
                        } else {
                            handicapName = "受" + handicapName;
                        }
//                                                看好客队的时候，把亚盘颠倒一下，因为存的都是按主队来说的，如果看好客队，比如主队是+，那么客队要变成减来计算
                        if (handicapName.contains("/")) {
                            String[] asianSplit = handicapName.split("/");
                            String abc = EnumCommon.asianMap.get(asianSplit[0]) + "/" + EnumCommon.asianMap.get(asianSplit[1]);
                            if ("-".equals(abc.substring(0, 1))) {
                                if (playInfoPO.getHomeScore() < playInfoPO.getVisitScore()) {
                                    if ("平手".equals(asianSplit[0]) && "半球".equals(asianSplit[1])) {
                                        winCount++;

                                    } else if ("半球".equals(asianSplit[0]) && "一球".equals(asianSplit[1])) {
                                        winCount++;

                                    } else if ("一球".equals(asianSplit[0]) && "球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 2) {
                                            winCount++;

                                        } else {

                                        }
                                    } else if ("球半".equals(asianSplit[0]) && "两球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 2) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("两球".equals(asianSplit[0]) && "两球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 3) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("两球半".equals(asianSplit[0]) && "三球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 3) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("三球".equals(asianSplit[0]) && "三球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 4) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("三球半".equals(asianSplit[0]) && "四球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 4) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("四球".equals(asianSplit[0]) && "四球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 5) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("四球半".equals(asianSplit[0]) && "五球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 5) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("五球".equals(asianSplit[0]) && "五球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 6) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("五球半".equals(asianSplit[0]) && "六球".equals(asianSplit[1])) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 6) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    }
                                } else {

                                }
                            } else {
//                                            加球
                                if (playInfoPO.getHomeScore() > playInfoPO.getVisitScore()) {
                                    if ("受一球".equals(asianSplit[0]) && "球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 2) {

                                        } else {
                                            winCount++;

                                        }
                                    } else if ("受球半".equals(asianSplit[0]) && "两球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 2) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受两球".equals(asianSplit[0]) && "两球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 3) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受两球半".equals(asianSplit[0]) && "三球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 3) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受三球".equals(asianSplit[0]) && "三球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 4) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受三球半".equals(asianSplit[0]) && "四球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 4) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受四球".equals(asianSplit[0]) && "四球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 5) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受四球半".equals(asianSplit[0]) && "五球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 5) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受五球".equals(asianSplit[0]) && "五球半".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 6) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受五球半".equals(asianSplit[0]) && "六球".equals(asianSplit[1])) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 6) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    }
                                } else {
                                    winCount++;

                                }
                            }
                        } else {
                            String abc = EnumCommon.asianMap.get(handicapName);
                            if (abc.contains("-")) {
                                if (playInfoPO.getHomeScore() <= playInfoPO.getVisitScore()) {
//                                                -0
                                    if ("平手".equals(handicapName)) {
                                        winCount++;

                                    } else if ("半球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() > playInfoPO.getHomeScore()) {
                                            winCount++;

                                        } else {

                                        }
                                    } else if ("一球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 1) {
                                            winCount++;

                                        } else {

                                        }
                                    } else if ("球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 2) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("两球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 2) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("两球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 3) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("三球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 3) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("三球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 4) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("四球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 4) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("四球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 5) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("五球".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 5) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    } else if ("五球半".equals(handicapName)) {
                                        if (playInfoPO.getVisitScore() - playInfoPO.getHomeScore() >= 6) {
//                                            winCount++;
                                            notCount++;
                                        } else {

                                        }
                                    }
                                } else {

                                }
                            } else {
                                if (playInfoPO.getHomeScore() >= playInfoPO.getVisitScore()) {
//                                                +0
                                    if ("受平手".equals(handicapName)) {
                                        if (Objects.equals(playInfoPO.getHomeScore(), playInfoPO.getVisitScore())) {
                                            winCount++;

                                        } else {

                                        }
                                    } else if ("受半球".equals(handicapName)) {
                                        if (Objects.equals(playInfoPO.getHomeScore(), playInfoPO.getVisitScore())) {
                                            winCount++;

                                        } else {

                                        }
                                    } else if ("受一球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 2) {

                                        } else {
                                            winCount++;

                                        }
                                    } else if ("受球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 2) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受两球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 3) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受两球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 3) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受三球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 4) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受三球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 4) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受四球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 5) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受四球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 5) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受五球".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 6) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    } else if ("受五球半".equals(handicapName)) {
                                        if (playInfoPO.getHomeScore() - playInfoPO.getVisitScore() >= 6) {

                                        } else {
//                                            winCount++;
                                            notCount++;
                                        }
                                    }
                                } else {
                                    winCount++;

                                }
                            }
                        }
                    }
                }

            }

            System.out.println("数量= " + winCount + "总数 = " + sumCount + "不算数的数量:" + notCount);
        }
    }

    /**
     * 判断方法
     */
    private Integer lookGood(BigDecimal home1, BigDecimal home2, BigDecimal draw1, BigDecimal draw2, BigDecimal
            visit1, BigDecimal visit2, int initialFlag, BigDecimal float02) {
        //                        左边小，中间不变，右边不变 (看好左)
        if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) == 0) {
            return 1;
        } else if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) > 0) {
//                            左边小，中间不变，右边变大 (看好左)
            return 1;
        } else if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) < 0) {
//                              左边小，中间不变，右边变小 (看好主胜或客胜)
            return 6;
        } else if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) == 0) {
//                            左边小，中间变大，右边不变 (看好左)
            return 1;
        } else if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) > 0) {
//                            左边小，中间变大，右边变大 (强烈看好左)
            return 1;
        } else if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) < 0) {
//                            左边小，中间变大，右边变小 (看好主胜或客胜)
            return 6;
        } else if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) == 0) {
//                            左边小，中间变小，右边不变 (主胜或平)
            return 2;
        } else if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) > 0) {
//                            左边小，中间变小，右边变大(看好主胜或平)
            return 2;
        } else if (home1.compareTo(home2) < 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) < 0) {
//                            左边小，中间变小，右边变小(看下一个庄，也如此则退出)
            return 0;
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) > 0) {
//                            左边不变，中间不变，右边变大(看初盘谁优势，左边优势就是主胜，右边优势就退出)
            if (initialFlag == 1) {
                return 1;
            } else {
                return 0;
            }
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) == 0) {
//                            左边不变，中间不变，右边不变(跳过看下一个庄，最多看2个庄)
            return 0;
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) < 0) {
//                            左边不变，中间不变，右边变小(看好客)
            return 5;
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) == 0) {
//                            左边不变，中间变大，右边不变(看初盘，谁优势就是看好谁胜)
            if (initialFlag == 1) {
                return 1;
            } else {
                return 5;
            }
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) > 0) {
//                            左边不变，中间变大，右边变大(看好主)
            return 1;
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) < 0) {
//                            左边不变，中间变大，右边变小(看好客)
            return 5;
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) > 0) {
//                            左边不变，中间变小，右边变大(看好主胜或平)
            return 2;
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) == 0) {
//                            左边不变，中间变小，右边不变(看哪边优势，主优则看好主胜或平，客优则看好客胜或平)
            if (initialFlag == 1) {
                return 2;
            } else {
                return 4;
            }
        } else if (home1.compareTo(home2) == 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) < 0) {
//                            左边不变，中间变小，右边变小(看好客胜或平)
            return 4;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) == 0) {
//                            左边大，中间不变，右边不变(如果初盘主占优则看下一个庄，如第2个庄也这样则退出。如果客占优则看好客胜)
            return 0;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) > 0) {
//                            左边大，中间不变，右边变大(看好平)
            return 3;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) == 0 && visit1.compareTo(visit2) < 0) {
//                            左边大，中间不变，右边变小(看好客)
            return 5;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) == 0) {
//                            左边大，中间变大，右边不变(看好客)
            return 5;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) > 0) {
//                            左边大，中间变大，右边变大(退出)
            return 0;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) > 0 && visit1.compareTo(visit2) < 0) {
//                            左边大，中间变大，右边变小(看好客)
            return 5;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) == 0) {
//                            左边大，中间变小，右边不变(看好客胜或平)
            return 4;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) > 0) {
//                            左边大，中间变小，右边变大(看好平)
            return 3;
        } else if (home1.compareTo(home2) > 0 && draw1.compareTo(draw2) < 0 && visit1.compareTo(visit2) < 0) {
//                            左边大，中间变小，右边变小(看好客胜或平)
            return 4;
        }
        return 0;
    }
}
